Locking

from uwsgiconf.runtime.locking import lock

@lock()
def locked():
    """This function will be locked with default (0) lock."""
    ...

 # or

with lock(2):
    # Code under this context manager will be locked with lock 2.
    ...
class uwsgiconf.runtime.locking.Lock(num: int = 0)

Locks related stuff.

Lock number 0 is always available. More locks need to be registered with .config.locking.set_basic_params(count=X) where X is the number of locks.

Note

The same lock should be released before next acquiring.

Can be used as context manager:

with Lock():
    do()

Can de used as a decorator:

@Lock()
def do():
    pass
Parameters:num – Lock number (0-64). 0 is always available and is used as default.
is_set

“Checks whether the lock is active.

Raises:ValueError – For Spooler or invalid lock number
acquire()

Sets the lock.

Raises:ValueError – For Spooler or invalid lock number
release()

Unlocks the lock.

Raises:ValueError – For Spooler or invalid lock number
uwsgiconf.runtime.locking.lock

Convenience alias for Lock.

alias of uwsgiconf.runtime.locking.Lock