Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Make the gevent workers handle the quit signal by deferring to a new greenlet #1128
Patch looks good. However I am wondering if there isn't a way to patch the signal handler when launching the worker. Indeed gevent.spawn is quite the same as a gevent.sleep or time.sleep when patched. I think it would worth to investigate this possibility imo.
@tilgovi Signals are delivered to the main greenlet, which happens to be the one running the hub---so the net result is the same on 1.0. So a complete stack trace captured there actually looks like this (captured with pdb):
Under 1.1, monkey patching signal only has any effect for SIGCHLD; everything else is left untouched and behaves just as it did in 1.0.
gevent does have a function gevent.signal that has the same effect as this patch (runs the handler in a new greenlet), but that API must be invoked directly---it is not monkey-patched in for compatibility.
Yes, there is a monkey patch on signal.signal in 1.1, but it only handles the case where the first argument is
import signal as _signal _signal_signal = _signal.signal # capture before patch def signal(signalnum, handler): """ Exactly the same as :func:`signal.signal` except where :const:`signal.SIGCHLD` is concerned. """ if signalnum != _signal.SIGCHLD: return _signal_signal(signalnum, handler) ...