Platform¶
Platform object is available in uwsgi
module attribute:
from uwsgiconf.runtime.platform import uwsgi
rss, vsz = uwsgi.memory
print(uwsgi.config)
@uwsgi.postfork_hooks.add()
def db_close_connections():
"""This will be called after fork()."""
print('Forked!')
-
class
uwsgiconf.runtime.platform.
_Platform
¶ -
request
¶ alias of
uwsgiconf.runtime.request._Request
-
postfork_hooks
¶ uWSGI is a preforking server, so you might need to execute a fixup tasks (hooks) after each fork(). Each hook will be executed in sequence on each process (worker/mule).
Note
The fork() happen before app loading, so there’s no hooks for dynamic apps. But one can still move postfork hooks in a .py file and import it on server startup with python.import_module().
alias of
_PostForkHooks
-
workers_count
= 0¶ Number of workers (processes) currently running.
-
cores_count
= 0¶ Detected number of processor cores.
-
buffer_size
= 0¶ The current configured buffer size in bytes.
-
threads_enabled
= False¶ Flag indicating whether thread support is enabled.
-
started_on
= 0¶ uWSGI’s startup Unix timestamp.
-
apps_map
= None¶ Applications dictionary mapping mountpoints to application callables.
-
hostname
¶ Current host name.
-
config
¶ The current configuration options, including any custom placeholders.
-
config_variables
¶ Current mapping of configuration file “magic” variables.
-
worker_id
¶ Returns current worker ID. 0 if not a worker (e.g. mule).
-
workers_info
¶ Gets statistics for all the workers for the current server.
Returns tuple of dicts.
-
ready_for_requests
¶ Returns flag indicating whether we are ready to handle requests.
-
master_pid
¶ Return the process identifier (PID) of the uWSGI master process.
-
memory
¶ Returns memory usage tuple of ints: (rss, vsz).
-
clock
¶ Returns uWSGI clock microseconds.
-
get_listen_queue
(socket_num: int = 0) → int¶ Returns listen queue (backlog size) of the given socket.
Parameters: socket_num – Socket number. Raises: ValueError – If socket is not found
-
get_version
(*, as_tuple: bool = False) → Union[str, Tuple[int, int, int, int, str]]¶ Returns uWSGI version string or tuple.
Parameters: as_tuple –
-
-
class
uwsgiconf.runtime.request.
_Request
¶ Current request information.
-
env
¶ Request environment dictionary.
-
id
¶ Returns current request number (handled by worker on core).
-
total_count
¶ Returns the total number of requests managed so far by the pool of uWSGI workers.
-
fd
¶ Returns current request file descriptor.
-
content_length
¶ Returns current post content length.
-
log
()¶ Instructs uWSGI to log current request data.
-
add_var
(name: str, value: str) → bool¶ Registers custom request variable.
Can be used for better integration with the internal routing subsystem.
Parameters: - name –
- value –
Raises: ValueError – If buffer size is not enough.
-