Skip to content

Make [Ctrl-C] exits with zen graceful in gUnicorn#483

Merged
bitterpanda63 merged 4 commits intomainfrom
fix-error-message-on-exit-gunicorn
Oct 6, 2025
Merged

Make [Ctrl-C] exits with zen graceful in gUnicorn#483
bitterpanda63 merged 4 commits intomainfrom
fix-error-message-on-exit-gunicorn

Conversation

@bitterpanda63
Copy link
Copy Markdown
Member

@bitterpanda63 bitterpanda63 commented Sep 17, 2025

Fixing error with gUnicorn [Ctrl-C], the process doesnt exit gracefully

[2025-09-17 13:15:55 +0200] [59997] [INFO] Handling signal: intTraceback (most recent call last):  File "/var/home/primary/.pyenv/versions/3.9.19/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap    self.run()  File "/var/home/primary/.pyenv/versions/3.9.19/lib/python3.9/multiprocessing/process.py", line 108, in run    self._target(*self._args, **self._kwargs)  File "/var/home/primary/Aikido/firewall-python/aikido_zen/background_process/aikido_background_process.py", line 50, in __init__    conn = listener.accept()  File "/var/home/primary/.pyenv/versions/3.9.19/lib/python3.9/multiprocessing/connection.py", line 463, in accept    c = self._listener.accept()  File "/var/home/primary/.pyenv/versions/3.9.19/lib/python3.9/multiprocessing/connection.py", line 609, in accept    s, self._last_accepted = self._socket.accept()  File "/var/home/primary/.pyenv/versions/3.9.19/lib/python3.9/socket.py", line 293, in accept    fd, addr = self._accept()KeyboardInterrupt[2025-09-17 13:15:55 +0200] [60078] [INFO] Worker exiting (pid: 60078)Error in atexit._run_exitfuncs:Traceback (most recent call last):  File "/var/home/primary/.pyenv/versions/3.9.19/lib/python3.9/multiprocessing/util.py", line 357, in _exit_function    p.join()  File "/var/home/primary/.pyenv/versions/3.9.19/lib/python3.9/multiprocessing/process.py", line 147, in join    assert self._parent_pid == os.getpid(), 'c

We fix this by not trying to start the background process outside of the forks (in gunicorn_config.py), and by adding graceful exit handlers to the background process

@bitterpanda63 bitterpanda63 changed the title Fix Ctrl-C errors for gunicorn Make [Ctrl-C] exits with zen graceful in gUnicorn Sep 17, 2025
@bitterpanda63 bitterpanda63 merged commit 3dc4610 into main Oct 6, 2025
102 of 104 checks passed
@bitterpanda63 bitterpanda63 deleted the fix-error-message-on-exit-gunicorn branch October 6, 2025 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants