Signals¶
-
class
uwsgiconf.runtime.signals.
SignalDescription
(num, target, func)¶ Registered signal information.
-
func
¶ Alias for field number 2
-
num
¶ Alias for field number 0
-
target
¶ Alias for field number 1
-
-
uwsgiconf.runtime.signals.
registry_signals
= []¶ Registered signals.
-
uwsgiconf.runtime.signals.
get_available_num
() → int¶ Returns first available signal number.
Raises: UwsgiconfException – If no signal is available.
-
uwsgiconf.runtime.signals.
get_last_received
() → uwsgiconf.runtime.signals.Signal¶ Get the last signal received.
-
class
uwsgiconf.runtime.signals.
Signal
(num: int = None)¶ Represents uWSGI signal.
Warning
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).
Note
If not set it will be chosen automatically.
-
registered
¶ 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:
worker
.workers
- run the signal handler on all the workersworkerN
- run the signal handler only on worker Nworker
/worker0
- run the signal handler on the first available workeractive-workers
- run the signal handlers on all the active [non-cheaped] workersmules
- run the signal handler on all of the mulesmuleN
- run the signal handler on mule Nmule
/mule0
- run the signal handler on the first available mulespooler
- run the signal on the first available spoolerfarmN/farm_XXX
- run the signal handler in the mule farm N or named XXX- http://uwsgi.readthedocs.io/en/latest/Signals.html#signals-targets
-
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.
Parameters: remote – Remote address.
Raises: - ValueError – If remote rejected the signal.
- OSError – If unable to deliver to remote.
-
wait
()¶ 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.
-