Signal — Signal watcher

class pyev.Signal(signum, loop, callback[, data=None, priority=0])
Parameters:
  • signum (int) – the signal number to monitor.
  • loop (Loop) – loop object responsible for this watcher (accessible through Watcher.loop).
  • callback (callable) – See Watcher.callback.
  • data (object) – any Python object you might want to attach to the watcher (stored in Watcher.data).
  • priority (int) – See Watcher.priority.

Signal watchers will trigger an event when the process receives a specific signal one or more times. Even though signals are very asynchronous, libev will try its best to deliver signals synchronously, i.e. as part of the normal event processing, like any other event.

You can configure as many watchers as you like for the same signal, but only within the same loop, i.e. you can watch for SIGINT in the default loop and for SIGIO in another loop, but you cannot watch for SIGINT in both the default loop and another loop at the same time. At the moment, SIGCHLD is permanently tied to the default loop.

If possible and supported, libev will install its handlers with SA_RESTART (or equivalent) behaviour enabled, so system calls should not be unduly interrupted. If you have a problem with system calls getting interrupted by signals you can block all signals in a Check watcher and unblock them in a Prepare watcher.

set(signum)
Parameters:signum (int) – the signal number to monitor.

Configures the watcher.

signum

Read only

The signal number being monitored.

Previous topic

Scheduler — Scheduler watcher

Next topic

Child — Child watcher

This Page