Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correct typing on signal handler (#664)
* fix: correct typing on signal handler the `signum` received in the signal handler is an `int`, not a `Signals` object. this leads to errors like so: ``` [2024-11-12 16:49:05,288] [PID 151] [MainThread] [dramatiq.ForkProcess(0)] [INFO] Stopping fork process... res = self._popen.wait(timeout) File "/usr/local/lib/python3.10/multiprocessing/popen_fork.py", line 43, in wait return self.poll(os.WNOHANG if timeout == 0.0 else 0) File "/usr/local/lib/python3.10/multiprocessing/popen_fork.py", line 27, in poll pid, sts = os.waitpid(self.pid, flag) File "/usr/local/lib/python3.10/site-packages/dramatiq/cli.py", line 579, in sighandler logger.info("Sending signal %r to subprocesses...", getattr(signum, "name", signum)) File "/usr/local/lib/python3.10/logging/__init__.py", line 1477, in info self._log(INFO, msg, args, **kwargs) File "/usr/local/lib/python3.10/logging/__init__.py", line 1624, in _log self.handle(record) File "/usr/local/lib/python3.10/logging/__init__.py", line 1634, in handle self.callHandlers(record) File "/usr/local/lib/python3.10/logging/__init__.py", line 1696, in callHandlers hdlr.handle(record) File "/usr/local/lib/python3.10/logging/__init__.py", line 966, in handle self.acquire() File "/usr/local/lib/python3.10/logging/__init__.py", line 917, in acquire self.lock.acquire() File "/usr/local/lib/python3.10/site-packages/dramatiq/cli.py", line 580, in sighandler stop_subprocesses(signum) File "/usr/local/lib/python3.10/site-packages/dramatiq/cli.py", line 571, in stop_subprocesses logger.warning("Failed to send %r to PID %d.", signum.name, proc.pid) AttributeError: 'int' object has no attribute 'name' ``` here, we correctly type the signal handler functions, and also convert the `int` to a `Signals` for consistency * cli: fix sort order --------- Co-authored-by: Bogdan Popa <[email protected]>
- Loading branch information