-
-
Notifications
You must be signed in to change notification settings - Fork 341
fix: graceful shutdown instead of SIGKILL on worker processes #1349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,9 +51,18 @@ def run_processes( | |
| ) | ||
|
|
||
| def terminating_signal_handler(_sig, _frame): | ||
| logger.info("Terminating server!!", bold=True) | ||
| logger.info("Gracefully shutting down server...", bold=True) | ||
| for process in process_pool: | ||
| process.kill() | ||
| process.terminate() | ||
|
|
||
| for process in process_pool: | ||
| process.join(timeout=30) | ||
| if process.is_alive(): | ||
| logger.warning("Process %s did not shut down in time, forcing kill.", process.pid) | ||
| process.kill() | ||
| process.join(timeout=5) | ||
|
|
||
| sys.exit(0) | ||
|
|
||
| signal.signal(signal.SIGINT, terminating_signal_handler) | ||
| signal.signal(signal.SIGTERM, terminating_signal_handler) | ||
|
|
@@ -220,6 +229,12 @@ def spawn_process( | |
| try: | ||
| server.start(socket, workers) | ||
| loop = asyncio.get_event_loop() | ||
|
|
||
| if not sys.platform.startswith("win32"): | ||
| loop.add_signal_handler(signal.SIGTERM, loop.stop) | ||
|
|
||
| loop.run_forever() | ||
| except KeyboardInterrupt: | ||
| pass | ||
| finally: | ||
| loop.close() | ||
|
Comment on lines
+233
to
240
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect whether workers have explicit SIGINT handling or process-group isolation.
rg -n -C2 'signal\.SIGINT|signal\.signal\(signal\.SIGINT|add_signal_handler\(signal\.SIGINT|start_new_session|setsid|setpgrp' .Repository: sparckles/Robyn Length of output: 1664 🏁 Script executed: # First, let's see the overall structure of processpool.py
head -100 robyn/processpool.py | cat -nRepository: sparckles/Robyn Length of output: 3620 🏁 Script executed: # Continue reading to see spawn_process and worker implementation
sed -n '100,250p' robyn/processpool.py | cat -nRepository: sparckles/Robyn Length of output: 5761 Workers can still bypass graceful shutdown on Ctrl+C. Only 🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolve — reviewed, signal handling is correct for the current architecture.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rate Limit Exceeded
|
||
Uh oh!
There was an error while loading. Please reload this page.