Claude Code Claude Opus 4.6 commited on
Commit
95dd22f
·
1 Parent(s): aa7928a

fix: Add CancelledError handling for graceful uvicorn shutdown

Browse files

Handle asyncio.CancelledError during uvicorn shutdown gracefully
instead of treating it as a fatal error. This prevents spurious
error logging when the server receives shutdown signals.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -2313,6 +2313,10 @@ if __name__ == "__main__":
2313
  _server_started = True
2314
  signal.alarm(0) # Cancel timeout
2315
  log_startup("Uvicorn server stopped normally")
 
 
 
 
2316
  except Exception as launch_error:
2317
  signal.alarm(0) # Cancel timeout
2318
  # Write to crash.log immediately
 
2313
  _server_started = True
2314
  signal.alarm(0) # Cancel timeout
2315
  log_startup("Uvicorn server stopped normally")
2316
+ except asyncio.CancelledError:
2317
+ signal.alarm(0) # Cancel timeout
2318
+ log_startup("Server shutdown cancelled gracefully")
2319
+ print("[INFO] Server shutdown requested - exiting cleanly")
2320
  except Exception as launch_error:
2321
  signal.alarm(0) # Cancel timeout
2322
  # Write to crash.log immediately