gevent.signal
– Cooperative implementation of special cases of signal.signal()
#
Cooperative implementation of special cases of signal.signal()
.
This module is designed to work with libev’s child watchers, as used
by default in gevent.os.fork()
Note that each SIGCHLD
handler will be run in a new greenlet when the signal is delivered
(just like gevent.hub.signal
)
The implementations in this module are only monkey patched if
gevent.os.waitpid()
is being used (the default) and if
signal.SIGCHLD
is available; see gevent.os.fork()
for
information on configuring this not to be the case for advanced uses.
New in version 1.1b4.
Changed in version 1.5a4: Previously there was a backwards compatibility alias
gevent.signal
, introduced in 1.1b4, that partly shadowed this
module, confusing humans and static analysis tools alike. That alias
has been removed. (See gevent.signal_handler
.)
- getsignal(signalnum)[source]#
Exactly the same as
signal.getsignal()
except wheresignal.SIGCHLD
is concerned.For
signal.SIGCHLD
, this cooperates withsignal()
to provide consistent answers.
- signal(signalnum, handler)[source]#
Exactly the same as
signal.signal()
except wheresignal.SIGCHLD
is concerned.Note
A
signal.SIGCHLD
handler installed with this function will only be triggered for children that are forked usinggevent.os.fork()
(gevent.os.fork_and_watch()
); children forked before monkey patching, or otherwise by the rawos.fork()
, will not trigger the handler installed by this function. (It’s unlikely that a SIGCHLD handler installed with the builtinsignal.signal()
would be triggered either; libev typically overwrites such a handler at the C level. At the very least, it’s full of race conditions.)Note
Use of
SIG_IGN
andSIG_DFL
may also have race conditions with libev child watchers and thegevent.subprocess
module.Changed in version 1.2a1: If
SIG_IGN
orSIG_DFL
are used to ignoreSIGCHLD
, a future use ofgevent.subprocess
and libev child watchers will once again work. However, on Python 2, use ofos.popen
will fail.Changed in version 1.1rc2: Allow using
SIG_IGN
andSIG_DFL
to reset and ignoreSIGCHLD
. However, this allows the possibility of a race condition ifgevent.subprocess
had already been used.