SignalDescription(num, target, func)¶
Registered signal information.
Alias for field number 2
Alias for field number 0
Alias for field number 1
get_available_num() → int¶
Returns first available signal number.
Raises: UwsgiconfException – If no signal is available.
get_last_received() → uwsgiconf.runtime.signals.Signal¶
Get the last signal received.
Signal(num: int = None)¶
Represents uWSGI signal.
If you define a new function in worker1 and register it as a signal handler, only worker1 can run it. The best way to register signals is defining them in the master (.runtime.uwsgi.postfork_hooks.add), so all workers see them.
signal = Signal() @signal.register_handler() def somefunc(): pass # or the same: @signal def somefunc(): pass
Parameters: num (int) –
Signal number (0-255).
If not set it will be chosen automatically.
Whether the signal is registered.
register_handler(*, target: str = None) → Callable¶
Decorator for a function to be used as a signal handler.
signal = Signal() @signal.register_handler() def somefunc(): pass
Parameters: target –
Where this signal will be delivered to. Default:
workers- run the signal handler on all the workers
workerN- run the signal handler only on worker N
worker0- run the signal handler on the first available worker
active-workers- run the signal handlers on all the active [non-cheaped] workers
mules- run the signal handler on all of the mules
muleN- run the signal handler on mule N
mule0- run the signal handler on the first available mule
spooler- run the signal on the first available spooler
farmN/farm_XXX- run the signal handler in the mule farm N or named XXX
send(*, remote: str = None)¶
Sends the signal to master or remote.
When you send a signal, it is copied into the master’s queue. The master will then check the signal table and dispatch the messages.
remote – Remote address.
- ValueError – If remote rejected the signal.
- OSError – If unable to deliver to remote.
Waits for the given of any signal.
Block the process/thread/async core until a signal is received. Use signal_received to get the number of the signal received. If a registered handler handles a signal, signal_wait will be interrupted and the actual handler will handle the signal.
Raises: SystemError – If something went wrong.