Skip to content

Control

from uwsgiconf.runtime.control import harakiri_imposed, reload

@harakiri_imposed(1)
def doomed():
    """Master process will kill this function after 1 sec."""

# or

with harakiri_imposed(30):
    # Master will kill worker if code under that manager won't finish in 30 sec.

# We'll reload uWSGI.
reload()

Classes

harakiri_imposed

harakiri_imposed(timeout: int)

Decorator and context manager.

Allows temporarily setting harakiri timeout for a function or a code block.

Note

This is for workers, mules and spoolers.

Examples:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
.. code-block:: python

    @harakiri_imposed(1)
    def doomed():
        do()


.. code-block:: python

    with harakiri_imposed(10):
        do()