Python uwsgi module stub

uwsgiconf comes with documented uwsgi module that you can import instead of import uwsgi.

# Instead of
import uwsgi

# you can do.
from uwsgiconf import uwsgi

That way uwsgi will be available runtime as usual, besides you will get autocompletion and hints in IDE, and won’t get ImportError when run without uwsgi.

This also will facilitate your testing a bit, for those simple cases when you won’t expect any result from uwsgi function.

Warning

This is a stub module, so it doesn’t really implement functions defined in it. Use it for documentation purposes.

uwsgiconf.uwsgi_stub.is_stub = True

Indicates whether stub is used instead of real uwsgi module.

uwsgiconf.uwsgi_stub.SPOOL_IGNORE = 0

Spooler function result.

Ignore this task, if multiple languages are loaded in the instance all of them will fight for managing the task. This return values allows you to skip a task in specific languages.

uwsgiconf.uwsgi_stub.SPOOL_OK = -2

Spooler function result.

The task has been completed, the spool file will be removed.

uwsgiconf.uwsgi_stub.SPOOL_RETRY = -1

Spooler function result.

Something is temporarily wrong, the task will be retried at the next spooler iteration.

uwsgiconf.uwsgi_stub.SymbolsImporter = None

SymbolsImporter type.

uwsgiconf.uwsgi_stub.SymbolsZipImporter = None

SymbolsZipImporter type.

uwsgiconf.uwsgi_stub.ZipImporter = None

ZipImporter type.

uwsgiconf.uwsgi_stub.applications = None

Applications dictionary mapping mountpoints to application callables.

Note

Can be None.

uwsgiconf.uwsgi_stub.buffer_size = 0

The current configured buffer size in bytes.

uwsgiconf.uwsgi_stub.cores = 0

Detected number of processor cores.

uwsgiconf.uwsgi_stub.env = {}

Request environment dictionary.

uwsgiconf.uwsgi_stub.has_threads = False

Flag indicating whether thread support is enabled.

uwsgiconf.uwsgi_stub.hostname = ''

Current host name.

uwsgiconf.uwsgi_stub.magic_table = {}

Current mapping of configuration file “magic” variables.

uwsgiconf.uwsgi_stub.numproc = 0

Number of workers (processes) currently running.

uwsgiconf.uwsgi_stub.opt = {}

The current configuration options, including any custom placeholders.

uwsgiconf.uwsgi_stub.post_fork_hook = <bound method type.run of <class 'uwsgiconf.runtime.platform._PostForkHooks'>>

Function to be called after process fork (spawning a new worker/mule).

uwsgiconf.uwsgi_stub.spooler = <bound method type._process_message_raw of <class 'uwsgiconf.runtime.spooler.Spooler'>>

Function to be called for spooler messages processing.

uwsgiconf.uwsgi_stub.sockets = []

Current list of file descriptors for registered sockets.

uwsgiconf.uwsgi_stub.start_response = None

Callable spitting UWSGI response.

uwsgiconf.uwsgi_stub.started_on = 0

uWSGI’s startup Unix timestamp.

uwsgiconf.uwsgi_stub.unbit = False

Unbit internal flag.

uwsgiconf.uwsgi_stub.version = '0.0.0'

The uWSGI version string.

Warning

Bytes are returned for Python 3.

Return type:bytes|str
uwsgiconf.uwsgi_stub.version_info = (0, 0, 0, 0, '')

Five-elements version number tuple.

Return type:tuple[int, int, int, int, bytes|str]
uwsgiconf.uwsgi_stub.mule_msg_hook(message)

Registers a function to be called for each mule message.

uwsgiconf.uwsgi_stub.accepting()

Called to notify the master that the worker is accepting requests, this is required for touch_chain_reload to work.

Return type:None
uwsgiconf.uwsgi_stub.add_cron(signal, minute, hour, day, month, weekday)

Adds cron. The interface to the uWSGI signal cron facility. The syntax is

Note

The last 5 arguments work similarly to a standard crontab, but instead of “*”, use -1, and instead of “/2”, “/3”, etc. use -2 and -3, etc.

Parameters:
  • signal (int) – Signal to raise.
  • minute (int) – Minute 0-59. Defaults to each.
  • hour (int) – Hour 0-23. Defaults to each.
  • day (int) – Day of the month number 1-31. Defaults to each.
  • month (int) – Month number 1-12. Defaults to each.
  • weekday (int) – Day of a the week number. Defaults to each. 0 - Sunday 1 - Monday 2 - Tuesday 3 - Wednesday 4 - Thursday 5 - Friday 6 - Saturday
Return type:

bool

Raises:

ValueError – If unable to add cron rule.

uwsgiconf.uwsgi_stub.add_file_monitor(signal, filename)

Maps a specific file/directory modification event to a signal.

Parameters:
  • signal (int) – Signal to raise.
  • filename (str|unicode) – File or a directory to watch for its modification.
Return type:

None

Raises:

ValueError – If unable to register monitor.

uwsgiconf.uwsgi_stub.add_ms_timer(signal, period)

Add a millisecond resolution timer.

Parameters:
  • signal (int) – Signal to raise.
  • period (int) – The interval (milliseconds) at which to raise the signal.
Return type:

None

Raises:

ValueError – If unable to add timer.

uwsgiconf.uwsgi_stub.add_rb_timer(signal, period, repeat=0)

Add a red-black timer.

Parameters:
  • signal (int) – Signal to raise.
  • period (int) – The interval (seconds) at which the signal is raised.
  • repeat (int) – How many times to send signal. Will stop after ther number is reached. Default: 0 - infinitely.
Return type:

None

Raises:

ValueError – If unable to add timer.

uwsgiconf.uwsgi_stub.add_timer(signal, period)

Add timer.

Parameters:
  • signal (int) – Signal to raise.
  • period (int) – The interval (seconds) at which to raise the signal.
Return type:

None

Raises:

ValueError – If unable to add timer.

uwsgiconf.uwsgi_stub.add_var(name, value)

Registers custom request variable.

Can be used for better integration with the internal routing subsystem.

Parameters:
  • name (str|unicode) –
  • value (str|unicode) –
Return type:

bool

Raises:

ValueError – If buffer size is not enough.

uwsgiconf.uwsgi_stub.alarm(name, message)

Issues the given alarm with the given message.

Parameters:
  • name (str|unicode) –
  • message (str|unicode) – Message to pass to alarm.
Return type:

None

uwsgiconf.uwsgi_stub.async_connect(socket)

Issues socket connection. And returns a file descriptor.

Parameters:socket (str|unicode) –
Return type:int
uwsgiconf.uwsgi_stub.async_sleep(seconds)

Suspends handling the current request and passes control to the next async core.

Parameters:seconds – Sleep time, in seconds.
Rtype None:
uwsgiconf.uwsgi_stub.cache_clear(cache)

Clears cache with the given name.

Parameters:cache (str|unicode) – Cache name with optional address (if @-syntax is used).
Return type:None
uwsgiconf.uwsgi_stub.cache_dec(key, value=1, expires=None, cache=None)

Decrements the specified key value by the specified value.

Parameters:
  • key (str|unicode) –
  • value (int) –
  • expires (int) – Expire timeout (seconds).
  • cache (str|unicode) – Cache name with optional address (if @-syntax is used).
Return type:

bool

uwsgiconf.uwsgi_stub.cache_del(key, cache=None)

Deletes the given cached key from the cache.

Parameters:
  • key (str|unicode) – The cache key to delete.
  • cache (str|unicode) – Cache name with optional address (if @-syntax is used).
Return type:

None

uwsgiconf.uwsgi_stub.cache_div(key, value=2, expires=None, cache=None)

Divides the specified key value by the specified value.

Parameters:
  • key (str|unicode) –
  • value (int) –
  • expires (int) – Expire timeout (seconds).
  • cache (str|unicode) – Cache name with optional address (if @-syntax is used).
Return type:

bool

uwsgiconf.uwsgi_stub.cache_exists(key, cache=None)

Checks whether there is a value in the cache associated with the given key.

Parameters:
  • key (str|unicode) – The cache key to check.
  • cache (str|unicode) – Cache name with optional address (if @-syntax is used).
Return type:

bool

uwsgiconf.uwsgi_stub.cache_get(key, cache=None)

Gets a value from the cache.

Warning

Bytes are returned for Python 3.

Parameters:
  • key (str|unicode) – The cache key to get value for.
  • cache (str|unicode) – Cache name with optional address (if @-syntax is used).
Return type:

bytes|str|None

uwsgiconf.uwsgi_stub.cache_inc(key, value=1, expires=None, cache=None)

Increments the specified key value by the specified value.

Parameters:
  • key (str|unicode) –
  • value (int) –
  • expires (int) – Expire timeout (seconds).
  • cache (str|unicode) – Cache name with optional address (if @-syntax is used).
Return type:

bool

uwsgiconf.uwsgi_stub.cache_keys(cache=None)

Returns a list of keys available in cache.

Parameters:cache (str|unicode) – Cache name with optional address (if @-syntax is used).
Return type:list
Raises:ValueError – If cache is unavailable.
uwsgiconf.uwsgi_stub.cache_mul(key, value=2, expires=None, cache=None)

Multiplies the specified key value by the specified value.

Parameters:
  • key (str|unicode) –
  • value (int) –
  • expires (int) – Expire timeout (seconds).
  • cache (str|unicode) – Cache name with optional address (if @-syntax is used).
Return type:

bool

uwsgiconf.uwsgi_stub.cache_num(key, cache=None)

Gets the 64bit number from the specified item.

Parameters:
  • key (str|unicode) – The cache key to get value for.
  • cache (str|unicode) – Cache name with optional address (if @-syntax is used).
Return type:

int|long|None

uwsgiconf.uwsgi_stub.cache_set(key, value, expires=None, cache=None)

Sets the specified key value.

Parameters:
  • key (str|unicode) –
  • value (str|unicode) –
  • expires (int) – Expire timeout (seconds).
  • cache (str|unicode) – Cache name with optional address (if @-syntax is used).
Return type:

bool

uwsgiconf.uwsgi_stub.cache_update(key, value, expires=None, cache=None)

Updates the specified key value.

Parameters:
  • key (str|unicode) –
  • value (int) –
  • expires (int) – Expire timeout (seconds).
  • cache (str|unicode) – Cache name with optional address (if @-syntax is used).
Return type:

bool

uwsgiconf.uwsgi_stub.call(func_name, *args)

Performs an [RPC] function call with the given arguments.

Warning

Bytes are returned for Python 3.

Parameters:
  • func_name (str|unicode) – Function name to call with optional address (if @-syntax is used).
  • args (list[str|bytes]) –
Return type:

bytes|str

uwsgiconf.uwsgi_stub.chunked_read(timeout)

Reads chunked input.

Warning

Bytes are returned for Python 3.

Parameters:timeout (int) – Wait timeout (seconds).
Return type:bytes|str
Raises:IOError – If unable to receive chunked part.
uwsgiconf.uwsgi_stub.chunked_read_nb()

Reads chunked input without blocking.

Warning

Bytes are returned for Python 3.

Return type:bytes|str
Raises:IOError – If unable to receive chunked part.
uwsgiconf.uwsgi_stub.cl()

Returns current post content length.

Return type:int|long
uwsgiconf.uwsgi_stub.close(fd)

Closes the given file descriptor.

Parameters:fd (int) – File descriptor.
Return type:None
uwsgiconf.uwsgi_stub.connect(socket, timeout=0)

Connects to the socket.

Parameters:
  • socket (str|unicode) – Socket name.
  • timeout (int) – Timeout (seconds).
Return type:

int

uwsgiconf.uwsgi_stub.connection_fd()

Returns current request file descriptor.

Return type:int
uwsgiconf.uwsgi_stub.disconnect()

Drops current connection.

Return type:None
uwsgiconf.uwsgi_stub.embedded_data(symbol_name)

Reads a symbol from the uWSGI binary image.

Warning

Bytes are returned for Python 3.

Parameters:symbol_name (str|unicode) – The symbol name to extract.
Return type:bytes|str
Raises:ValueError – If symbol is unavailable.
uwsgiconf.uwsgi_stub.extract(fname)

Extracts file contents.

Warning

Bytes are returned for Python 3.

Parameters:fname (str|unicode) –
Return type:bytes|str
uwsgiconf.uwsgi_stub.farm_get_msg()

Reads a mule farm message.

Warning

Bytes are returned for Python 3.

Return type:bytes|str|None
Raises:ValueError – If not in a mule
uwsgiconf.uwsgi_stub.farm_msg(farm, message)

Sends a message to the given farm.

Parameters:
  • farm (str|unicode) – Farm name to send message to.
  • message (str|unicode) –
Return type:

None

uwsgiconf.uwsgi_stub.get_logvar(name)

Return user-defined log variable contents.

Warning

Bytes are returned for Python 3.

Parameters:name (str|unicode) –
Return type:bytes|str
uwsgiconf.uwsgi_stub.green_schedule()

Switches to another green thread.

Note

Alias for suspend.

Type:bool
uwsgiconf.uwsgi_stub.i_am_the_spooler()

Returns flag indicating whether you are the Spooler.

Return type:bool
uwsgiconf.uwsgi_stub.in_farm(name)

Returns flag indicating whether you are (mule) belong to the given farm.

Parameters:name (str|unicode) – Farm name.
Return type:bool
uwsgiconf.uwsgi_stub.is_a_reload()

Returns flag indicating whether reloading mechanics is used.

Return type:bool
uwsgiconf.uwsgi_stub.is_connected(fd)

Checks the given file descriptor.

Parameters:fd (int) – File descriptor
Return type:bool
uwsgiconf.uwsgi_stub.is_locked(lock_num=0)

Checks for the given lock.

Note

Lock 0 is always available.

Parameters:lock_num (int) – Lock number.
Return type:bool
Raises:ValueError – For Spooler or invalid lock number
uwsgiconf.uwsgi_stub.listen_queue(socket_num=0)

Returns listen queue (backlog size) of the given socket.

Parameters:socket_num (int) – Socket number.
Return type:int
Raises:ValueError – If socket is not found
uwsgiconf.uwsgi_stub.lock(lock_num=0)

Sets the given lock.

Note

Lock 0 is always available.

Parameters:lock_num (int) – Lock number.
Return type:None
Raises:ValueError – For Spooler or invalid lock number
uwsgiconf.uwsgi_stub.log(message)

Logs a message.

Parameters:message (str|unicode) –
Return type:bool
uwsgiconf.uwsgi_stub.log_this_request()

Instructs uWSGI to log current request data.

Return type:None
uwsgiconf.uwsgi_stub.logsize()

Returns current log size.

Return type:long
uwsgiconf.uwsgi_stub.loop()

Returns current event loop name or None if loop is not set.

Return type:st|unicode|None
uwsgiconf.uwsgi_stub.masterpid()

Return the process identifier (PID) of the uWSGI master process.

Return type:int
uwsgiconf.uwsgi_stub.mem()

Returns memory usage tuple of ints: (rss, vsz).

Return type:tuple
uwsgiconf.uwsgi_stub.metric_dec(key, value=1)

Decrements the specified metric key value by the specified value.

Parameters:
  • key (str|unicode) –
  • value (int) –
Return type:

bool

uwsgiconf.uwsgi_stub.metric_div(key, value=1)

Divides the specified metric key value by the specified value.

Parameters:
  • key (str|unicode) –
  • value (int) –
Return type:

bool

uwsgiconf.uwsgi_stub.metric_get(key)

Returns metric value by key.

Parameters:key (str|unicode) –
Return type:int|long
uwsgiconf.uwsgi_stub.metric_inc(key, value=1)

Increments the specified metric key value by the specified value.

Parameters:
  • key (str|unicode) –
  • value (int) –
Return type:

bool

uwsgiconf.uwsgi_stub.metric_mul(key, value=1)

Multiplies the specified metric key value by the specified value.

Parameters:
  • key (str|unicode) –
  • value (int) –
Return type:

bool

uwsgiconf.uwsgi_stub.metric_set(key, value)

Sets metric value.

Parameters:
  • key (str|unicode) –
  • value (int|long) –
Return type:

bool

uwsgiconf.uwsgi_stub.metric_set_max(key, value)

Sets metric value if it is greater that the current one.

Parameters:
  • key (str|unicode) –
  • value (int|long) –
Return type:

bool

uwsgiconf.uwsgi_stub.metric_set_min(key, value)

Sets metric value if it is less that the current one.

Parameters:
  • key (str|unicode) –
  • value (int|long) –
Return type:

bool

uwsgiconf.uwsgi_stub.micros()

Returns uWSGI clock microseconds.

Return type:long
uwsgiconf.uwsgi_stub.mule_get_msg(signals=None, farms=None, buffer_size=65536, timeout=-1)

Block until a mule message is received and return it.

This can be called from multiple threads in the same programmed mule.

Warning

Bytes are returned for Python 3.

Parameters:
  • signals (bool) – Whether to manage signals.
  • farms (bool) – Whether to manage farms.
  • buffer_size (int) –
  • timeout (int) – Seconds.
Return type:

bytes|str

Raises:

ValueError – If not in a mule.

uwsgiconf.uwsgi_stub.mule_id()

Returns current mule ID. 0 if not a mule (e.g. worker).

Return type:int
uwsgiconf.uwsgi_stub.mule_msg(message, mule_farm=None)

Sends a message to a mule(s)/farm.

Parameters:
  • message (str|unicode) –
  • mule_farm – Mule ID, or farm name.
Return type:

bool

Raises:

ValueError – If no mules, or mule ID or farm name is not recognized.

uwsgiconf.uwsgi_stub.offload(filename)

Offloads a file.

Warning

Currently not implemented.

Parameters:filename
Return type:bytes|str
Raises:ValueError – If unable to offload.
uwsgiconf.uwsgi_stub.parsefile(fpath)

Parses the given file.

Currently implemented only Spooler file parsing.

Parameters:fpath (str|unicode) –
Return type:None
uwsgiconf.uwsgi_stub.ready()

Returns flag indicating whether we are ready to handle requests.

Return type:bool
uwsgiconf.uwsgi_stub.ready_fd()

Returns flag indicating whether file description related to request is ready.

Return type:bool
uwsgiconf.uwsgi_stub.recv(fd, maxsize=4096)

Reads data from the given file descriptor.

Warning

Bytes are returned for Python 3.

Parameters:
  • fd (int) –
  • maxsize (int) – Chunk size (bytes).
Return type:

bytes|str

uwsgiconf.uwsgi_stub.register_rpc(name, func)

Registers RPC function.

Parameters:
  • name (str|unicode) –
  • func (callable) –
Return type:

bool

Raises:

ValueError – If unable to register function

uwsgiconf.uwsgi_stub.register_signal(number, target, func)

Registers a signal handler.

Parameters:
  • number (int) – Signal number.
  • target (str|unicode) –
    • workers - run the signal handler on all the workers
    • workerN - run the signal handler only on worker N
    • worker/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
    • mule/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
    • http://uwsgi.readthedocs.io/en/latest/Signals.html#signals-targets
  • func (callable) –
Return type:

None

Raises:

ValueError – If unable to register

uwsgiconf.uwsgi_stub.reload()

Gracefully reloads uWSGI.

Return type:bool
uwsgiconf.uwsgi_stub.request_id()

Returns current request number (handled by worker on core).

Return type:int
uwsgiconf.uwsgi_stub.route(name, args_str)

Registers a named route for internal routing subsystem.

Parameters:
  • name (str) – Route name
  • args_str – Comma-separated arguments string.
Return type:

int

uwsgiconf.uwsgi_stub.rpc(address, func_name, *args)

Performs an RPC function call with the given arguments.

Warning

Bytes are returned for Python 3.

Parameters:
  • address (str|unicode) –
  • func_name (str|unicode) – Function name to call.
  • args (list[str|bytes]) –
Return type:

bytes|str

Raises:

ValueError – If unable to call RPC function.

uwsgiconf.uwsgi_stub.rpc_list()

Returns registered RPC functions names.

Return type:tuple
uwsgiconf.uwsgi_stub.send(fd_or_data, data=None)

Puts data into file descriptor.

  • One argument. Data to write into request file descriptor.
  • Two arguments. 1. File descriptor; 2. Data to write.
Parameters:
  • df_or_data
  • data
Return type:

bool

uwsgiconf.uwsgi_stub.sendfile(fd_or_name, chunk_size=0, start_pos=0, filesize=0)

Runs a sendfile.

Parameters:
  • fd_or_name (int|str|unicode) – File path or descriptor number.
  • chunk_size (int) – Not used.
  • start_pos (int) –
  • filesize (int) – Filesize. If 0 will be determined automatically.
Return type:

bool|None

uwsgiconf.uwsgi_stub.send_to_spooler(message=None, **kwargs)

Send data to the The uWSGI Spooler. Also known as spool().

Warning

Either message argument should contain a dictionary this message dictionary will be constructed from kwargs.

Parameters:
  • bytes] message (dict[bytes,) – The message to spool. Keys and values are bytes.
  • kwargs (dict) –

    Possible kwargs (these are also reserved message argument dictionary keys):

    • spooler: The spooler (id or directory) to use.
      Specify the ABSOLUTE path of the spooler that has to manage this task
    • priority: Number. The priority of the message. Larger - less important.

      Warning

      This works only if you enable order_tasks option in spooler.set_basic_params().

      This will be the subdirectory in the spooler directory in which the task will be placed, you can use that trick to give a good-enough prioritization to tasks.

      Note

      This is for systems with few resources. For better approach use multiple spoolers.

    • at: Unix time at which the task must be executed.
      The task will not be run until the ‘at’ time is passed.
    • body: A binary body to add to the message,
      in addition to the message dictionary itself. Use this key for objects bigger than 64k, the blob will be appended to the serialized uwsgi packet and passed back t o the spooler function as the ‘body’ argument.
Return type:

str|None

uwsgiconf.uwsgi_stub.set_logvar(name, value)

Sets log variable.

Parameters:
  • name (str|unicode) –
  • value (str|unicode) –
Return type:

None

uwsgiconf.uwsgi_stub.set_spooler_frequency(seconds)

Sets how often the spooler runs.

Parameters:seconds (int) –
Return type:bool
uwsgiconf.uwsgi_stub.set_user_harakiri(timeout=0)

Sets user level harakiri.

Parameters:timeout (int) – Seconds. 0 disable timer.
Return type:None
uwsgiconf.uwsgi_stub.set_warning_message(message)

Sets a warning. This will be reported by pingers.

Parameters:message (str|unicode) –
Return type:bool
uwsgiconf.uwsgi_stub.setprocname(name)

Sets current process name.

Parameters:name (str|unicode) –
Return type:bool
uwsgiconf.uwsgi_stub.signal(num, remote='')

Sends the signal to master or remote.

Parameters:
  • num – Signal number.
  • remote (str|unicode) – Remote address.
Return type:

None

Raises:
  • ValueError – If remote rejected the signal.
  • IOError – If unable to deliver to remote.
uwsgiconf.uwsgi_stub.signal_received()

Get the number of the last signal received.

Used in conjunction with signal_wait.

Return type:int
uwsgiconf.uwsgi_stub.signal_registered(num)

Verifies the given signal has been registered.

Parameters:num (int) –
Return type:bool|None
uwsgiconf.uwsgi_stub.signal_wait(num=None)

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.

Parameters:num (int) –
Return type:str|unicode
Raises:SystemError – If something went wrong.
uwsgiconf.uwsgi_stub.spool(message=None, **kwargs)

Send data to the The uWSGI Spooler. Also known as spool().

Warning

Either message argument should contain a dictionary this message dictionary will be constructed from kwargs.

Parameters:
  • bytes] message (dict[bytes,) – The message to spool. Keys and values are bytes.
  • kwargs (dict) –

    Possible kwargs (these are also reserved message argument dictionary keys):

    • spooler: The spooler (id or directory) to use.
      Specify the ABSOLUTE path of the spooler that has to manage this task
    • priority: Number. The priority of the message. Larger - less important.

      Warning

      This works only if you enable order_tasks option in spooler.set_basic_params().

      This will be the subdirectory in the spooler directory in which the task will be placed, you can use that trick to give a good-enough prioritization to tasks.

      Note

      This is for systems with few resources. For better approach use multiple spoolers.

    • at: Unix time at which the task must be executed.
      The task will not be run until the ‘at’ time is passed.
    • body: A binary body to add to the message,
      in addition to the message dictionary itself. Use this key for objects bigger than 64k, the blob will be appended to the serialized uwsgi packet and passed back t o the spooler function as the ‘body’ argument.
Return type:

str|None

uwsgiconf.uwsgi_stub.spooler_get_task(path)

Returns a spooler task information.

Parameters:path (str) – The relative or absolute path to the task to read.
Return type:dict|None
uwsgiconf.uwsgi_stub.spooler_jobs()

Returns a list of spooler jobs (filenames in spooler directory).

Return type:list[str]
uwsgiconf.uwsgi_stub.spooler_pid()

Returns first spooler process ID

Return type:int
uwsgiconf.uwsgi_stub.spooler_pids()

Returns a list of all spooler processes IDs.

Return type:list[int]
uwsgiconf.uwsgi_stub.stop()

Stops uWSGI.

Return type:bool|None
uwsgiconf.uwsgi_stub.suspend()

Suspends handling of current coroutine/green thread and passes control to the next async core.

Return type:bool
uwsgiconf.uwsgi_stub.total_requests()

Returns the total number of requests managed so far by the pool of uWSGI workers.

Return type:int
uwsgiconf.uwsgi_stub.unlock(lock_num=0)

Unlocks the given lock.

Note

Lock 0 is always available.

Parameters:lock_num (int) – Lock number.
Return type:None
Raises:ValueError – For Spooler or invalid lock number
uwsgiconf.uwsgi_stub.wait_fd_read(fd, timeout=None)

Suspends handling of the current request until there is something to be read on file descriptor.

May be called several times before yielding/suspending to add more file descriptors to the set to be watched.

Parameters:
  • fd (int) – File descriptor number.
  • timeout (int) – Timeout. Default: infinite.
Return type:

bytes|str

Raises:

IOError – If unable to read.

uwsgiconf.uwsgi_stub.wait_fd_write(fd, timeout=None)

Suspends handling of the current request until there is nothing more to be written on file descriptor.

May be called several times to add more file descriptors to the set to be watched.

Parameters:
  • fd (int) – File descriptor number.
  • timeout (int) – Timeout. Default: infinite.
Return type:

bytes|str

Raises:

IOError – If unable to read.

uwsgiconf.uwsgi_stub.websocket_handshake(security_key=None, origin=None, proto=None)

Waits for websocket handshake.

Parameters:
  • security_key (str|unicode) – Websocket security key to use.
  • origin (str|unicode) – Override Sec-WebSocket-Origin.
  • proto (str|unicode) – Override Sec-WebSocket-Protocol.
Return type:

None

Raises:

IOError – If unable to complete handshake.

uwsgiconf.uwsgi_stub.websocket_recv(request_context=None)

Receives data from websocket.

Parameters:request_context
Return type:bytes|str
Raises:IOError – If unable to receive a message.
uwsgiconf.uwsgi_stub.websocket_recv_nb(request_context=None)

Receives data from websocket (non-blocking variant).

Parameters:request_context
Return type:bytes|str
Raises:IOError – If unable to receive a message.
uwsgiconf.uwsgi_stub.websocket_send(message, request_context=None)

Sends a message to websocket.

Parameters:
  • message (str) – data to send
  • request_context
Raises:

IOError – If unable to send a message.

uwsgiconf.uwsgi_stub.websocket_send_binary(message, request_context=None)

Sends binary message to websocket.

Parameters:
  • message (str) – data to send
  • request_context
Raises:

IOError – If unable to send a message.

uwsgiconf.uwsgi_stub.worker_id()

Returns current worker ID. 0 if not a worker (e.g. mule).

Return type:int
uwsgiconf.uwsgi_stub.workers()

Gets statistics for all the workers for the current server.

Returns tuple of dicts.

Return type:tuple[dict]
uwsgiconf.uwsgi_stub.i_am_the_lord(legion_name)

Returns flag indicating whether you are the lord of the given legion.

Parameters:legion_name (str|unicode) –
Return type:bool
uwsgiconf.uwsgi_stub.lord_scroll(legion_name)

Returns a Lord scroll for the Legion.

Parameters:legion_name (str|unicode) –
Return type:bool
uwsgiconf.uwsgi_stub.scrolls(legion_name)

Returns a list of Legion scrolls defined on cluster.

Parameters:legion_name (str|unicode) –
Return type:list