signature
stringlengths
8
3.44k
body
stringlengths
0
1.41M
docstring
stringlengths
1
122k
id
stringlengths
5
17
def _get_name(self, *args, **kwargs):
return self.name<EOL>
:rtype: str
f13037:c2:m1
def __call__(self, *args, **kwargs):
return self.set_basic_params(*args, **kwargs)<EOL>
The call is translated into ``set_basic_params``` call. This approach is much more convenient yet IDE most probably won't give you a hint on what arguments are accepted. :param args: :param kwargs: :rtype: Section
f13037:c2:m3
def set_basic_params(self, *args, **kwargs):
return self._section<EOL>
:rtype: Section
f13037:c2:m6
def _set(self, key, value, condition=True, cast=None, multi=False, plugin=None, priority=None):
key = OptionKey(key)<EOL>def set_plugin(plugin):<EOL><INDENT>self._section.set_plugins_params(plugins=plugin)<EOL><DEDENT>def handle_priority(value, use_list=False):<EOL><INDENT>if priority is not None:<EOL><INDENT>opts_copy = opts.copy()<EOL>opts.clear()<EOL>existing_value = opts_copy.pop(key, [])<EOL>if use_list:<EOL><INDENT>existing_value.extend(value)<EOL>value = existing_value<EOL><DEDENT>for pos, (item_key, item_val) in enumerate(opts_copy.items()):<EOL><INDENT>if priority == pos:<EOL><INDENT>opts[key] = value<EOL><DEDENT>opts[item_key] = item_val<EOL><DEDENT>return True<EOL><DEDENT><DEDENT>def handle_plugin_required(val):<EOL><INDENT>if isinstance(val, ParametrizedValue):<EOL><INDENT>key.swap(val.opt_key or key) <EOL>if val.plugin:<EOL><INDENT>set_plugin(val.plugin)<EOL><DEDENT>if val._opts:<EOL><INDENT>opts.update(val._opts)<EOL><DEDENT><DEDENT><DEDENT>if condition is True:<EOL><INDENT>condition = value is not None<EOL><DEDENT>if condition is None or condition:<EOL><INDENT>opts = self._section._opts<EOL>if cast is bool:<EOL><INDENT>if value:<EOL><INDENT>value = '<STR_LIT:true>'<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>del opts[key]<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT>return<EOL><DEDENT><DEDENT>if self.plugin is True:<EOL><INDENT>set_plugin(self)<EOL><DEDENT>if plugin:<EOL><INDENT>set_plugin(plugin)<EOL><DEDENT>if isinstance(value, tuple): <EOL><INDENT>list(map(handle_plugin_required, value))<EOL>value = '<STR_LIT:U+0020>'.join(map(str, value))<EOL><DEDENT>if multi:<EOL><INDENT>values = []<EOL>for value in listify(value):<EOL><INDENT>handle_plugin_required(value)<EOL>values.append(value)<EOL><DEDENT>if not handle_priority(values, use_list=True):<EOL><INDENT>opts.setdefault(key, []).extend(values)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>handle_plugin_required(value)<EOL>if not handle_priority(value):<EOL><INDENT>opts[key] = value<EOL><DEDENT><DEDENT><DEDENT>
:param str|unicode key: Option name :param value: Option value. Can be a lis if ``multi``. :param condition: Condition to test whether this option should be added to section. * True - test value is not None. :param cast: Value type caster. * bool - treat value as a flag :param bool multi: Indicate that many options can use the same name. :param str|unicode plugin: Plugin this option exposed by. Activated automatically. :param int priority: Option priority indicator. Options with lower numbers will come first.
f13037:c2:m7
def __init__(self, address, prefix=None):
super(PusherSocket, self).__init__(address, prefix)<EOL>
:param str|unicode address: :param str|unicode prefix: Arbitrary prefix to differentiate sender.
f13038:c1:m0
def __init__(self, target_dir, library=None, push_interval=None):
super(PusherRrdtool, self).__init__(target_dir)<EOL>self._set('<STR_LIT>', push_interval)<EOL>self._set('<STR_LIT>', library)<EOL>
:param str|unicode target_dir: Directory to store rrd files into. :param str|unicode library: Set the name of rrd library. Default: librrd.so. :param int push_interval: Set push frequency.
f13038:c2:m0
def __init__(self, address, prefix=None, no_workers=None, all_gauges=None):
super(PusherStatsd, self).__init__(address, prefix)<EOL>self._set('<STR_LIT>', no_workers, cast=bool)<EOL>self._set('<STR_LIT>', all_gauges, cast=bool)<EOL>
:param str|unicode address: :param str|unicode prefix: Arbitrary prefix to differentiate sender. :param bool no_workers: Disable generation of single worker metrics. :param bool all_gauges: Push all metrics to statsd as gauges.
f13038:c3:m0
def __init__(<EOL>self, address, node_realm=None, node_root=None, push_interval=None, idle_avg_source=None,<EOL>use_metrics=None, no_workers=None, timeout=None, retries=None, retries_delay=None,<EOL>hostname_dots_replacer=None):
super(PusherCarbon, self).__init__(address)<EOL>self._set('<STR_LIT>', node_realm)<EOL>self._set('<STR_LIT>', node_root)<EOL>self._set('<STR_LIT>', push_interval)<EOL>self._set('<STR_LIT>', idle_avg_source)<EOL>self._set('<STR_LIT>', use_metrics, cast=bool)<EOL>self._set('<STR_LIT>', no_workers, cast=bool)<EOL>self._set('<STR_LIT>', timeout)<EOL>self._set('<STR_LIT>', retries)<EOL>self._set('<STR_LIT>', retries_delay)<EOL>self._set('<STR_LIT>', hostname_dots_replacer)<EOL>if not address.split('<STR_LIT::>')[<NUM_LIT:0>].replace('<STR_LIT:.>', '<STR_LIT>').isdigit():<EOL><INDENT>self._set('<STR_LIT>', True, cast=bool)<EOL><DEDENT>
:param str|unicode|list[str|unicode] address: Host and port. Example: 127.0.0.1:2004 :param str|unicode node_realm: Set carbon metrics realm node. :param str|unicode node_root: Set carbon metrics root node. Default: uwsgi. :param int push_interval: Set carbon push frequency in seconds. Default: 60. :param bool no_workers: Disable generation of single worker metrics. :param str|unicode idle_avg_source: Average values source during idle period (no requests). Variants: * last (default) * zero * none :param bool use_metrics: Don't compute all statistics, use metrics subsystem data instead. .. warning:: Key names of built-in stats are different from those of metrics system. :param int timeout: Set carbon connection timeout in seconds. Default: 3. :param int retries: Set maximum number of retries in case of connection errors. Default: 1. :param int retries_delay: Set connection retry delay in seconds. Default: 7. :param str|unicode hostname_dots_replacer: Set char to use as a replacement for dots in hostname in `<node_root>.hostname.<node_realm>.metrics_data`` This affects Graphite aggregation mechanics. .. note:: Dots are not replaced by default.
f13038:c4:m0
def __init__(self, address, prefix=None, template=None):
super(PusherZabbix, self).__init__(address, prefix)<EOL>self._set('<STR_LIT>', template)<EOL>
:param str|unicode address: :param str|unicode prefix: Arbitrary prefix to differentiate sender. :param str|unicode template: Print (or store to a file) the zabbix template for the current metrics setup.
f13038:c5:m0
def __init__(self, address=None, collection=None, push_interval=None):
value = KeyValue(locals(), aliases={'<STR_LIT>': '<STR_LIT>'})<EOL>super(PusherMongo, self).__init__(value)<EOL>
:param str|unicode address: Default: 127.0.0.1:27017 :param str|unicode collection: MongoDB colection to write into. Default: uwsgi.statistics :param int push_interval: Write interval in seconds.
f13038:c6:m0
def __init__(self, fpath=None, separator=None, push_interval=None):
value = KeyValue(locals(), aliases={'<STR_LIT>': '<STR_LIT:path>', '<STR_LIT>': '<STR_LIT>'})<EOL>super(PusherFile, self).__init__(value)<EOL>
:param str|unicode fpath: File path. Default: uwsgi.stats :param str|unicode separator: New entry separator. Default: \n\n :param int push_interval: Write interval in seconds.
f13038:c7:m0
def set_basic_params(<EOL>self, no_requests=None, template=None, memory_report=None, prefix=None, prefix_date=None,<EOL>apply_strftime=None, response_ms=None, ip_x_forwarded=None):
self._set('<STR_LIT>', no_requests, cast=bool)<EOL>self._set('<STR_LIT>', template)<EOL>self._set('<STR_LIT>', memory_report)<EOL>self._set('<STR_LIT>', prefix)<EOL>if isinstance(prefix_date, string_types) and '<STR_LIT:%>' in prefix_date:<EOL><INDENT>prefix_date = prefix_date.replace('<STR_LIT:%>', '<STR_LIT>') <EOL><DEDENT>self._set('<STR_LIT>', prefix_date, cast=(bool if isinstance(prefix_date, bool) else None))<EOL>self._set('<STR_LIT>', apply_strftime, cast=bool)<EOL>self._set('<STR_LIT>', response_ms, cast=bool)<EOL>self._set('<STR_LIT>', ip_x_forwarded, cast=bool)<EOL>return self._section<EOL>
:param bool no_requests: Disable requests logging - only uWSGI internal messages and errors will be logged. :param str|unicode template: Set advanced format for request logging. This template string can use variables from ``Logging.Vars``. :param str|unicode prefix: Prefix log items with a string. :param str|unicode|bool prefix_date: Prefix log items with date string. .. note:: This can be ``True`` or contain formatting placeholders (e.g. %Y-%m-%d %H:%M:%S) if used with ``apply_strftime``. :param int memory_report: Enable memory report. * **1** - basic (default); * **2** - uss/pss (Linux only) :param bool apply_strftime: Apply strftime to dates in log entries. E.g. ``prefix_date`` can contain format placeholders. See also ``vars.REQ_START_FORMATTED``. :param bool response_ms: Report response time in microseconds instead of milliseconds. :param bool ip_x_forwarded: Use the IP from X-Forwarded-For header instead of REMOTE_ADDR. Used when uWSGI is run behind multiple proxies.
f13039:c3:m0
def log_into(self, target, before_priv_drop=True):
command = '<STR_LIT>'<EOL>if not before_priv_drop:<EOL><INDENT>command += '<STR_LIT:2>'<EOL><DEDENT>self._set(command, target)<EOL>return self._section<EOL>
Simple file or UDP logging. .. note:: This doesn't require any Logger plugin and can be used if no log routing is required. :param str|unicode target: Filepath or UDP address. :param bool before_priv_drop: Whether to log data before or after privileges drop.
f13039:c3:m1
def set_file_params(<EOL>self, reopen_on_reload=None, trucate_on_statup=None, max_size=None, rotation_fname=None,<EOL>touch_reopen=None, touch_rotate=None, owner=None, mode=None):
self._set('<STR_LIT>', reopen_on_reload, cast=bool)<EOL>self._set('<STR_LIT>', trucate_on_statup, cast=bool)<EOL>self._set('<STR_LIT>', max_size)<EOL>self._set('<STR_LIT>', rotation_fname)<EOL>self._set('<STR_LIT>', touch_reopen, multi=True)<EOL>self._set('<STR_LIT>', touch_rotate, multi=True)<EOL>self._set('<STR_LIT>', owner)<EOL>self._set('<STR_LIT>', mode)<EOL>return self._section<EOL>
Set various parameters related to file logging. :param bool reopen_on_reload: Reopen log after reload. :param bool trucate_on_statup: Truncate log on startup. :param int max_size: Set maximum logfile size in bytes after which log should be rotated. :param str|unicode rotation_fname: Set log file name after rotation. :param str|unicode|list touch_reopen: Trigger log reopen if the specified file is modified/touched. .. note:: This can be set to a file touched by ``postrotate`` script of ``logrotate`` to implement rotation. :param str|unicode|list touch_rotate: Trigger log rotation if the specified file is modified/touched. :param str|unicode owner: Set owner chown() for logs. :param str|unicode mode: Set mode chmod() for logs.
f13039:c3:m2
def set_filters(self, include=None, exclude=None, write_errors=None, write_errors_tolerance=None, sigpipe=None):
if write_errors is not None:<EOL><INDENT>self._set('<STR_LIT>', not write_errors, cast=bool)<EOL><DEDENT>if sigpipe is not None:<EOL><INDENT>self._set('<STR_LIT>', not sigpipe, cast=bool)<EOL><DEDENT>self._set('<STR_LIT>', write_errors_tolerance)<EOL>for line in listify(include):<EOL><INDENT>self._set('<STR_LIT>', line, multi=True)<EOL><DEDENT>for line in listify(exclude):<EOL><INDENT>self._set('<STR_LIT>', line, multi=True)<EOL><DEDENT>return self._section<EOL>
Set various log data filters. :param str|unicode|list include: Show only log lines matching the specified regexp. .. note:: Requires enabled PCRE support. :param str|unicode|list exclude: Do not show log lines matching the specified regexp. .. note:: Requires enabled PCRE support. :param bool write_errors: Log (annoying) write()/writev() errors. Default: ``True``. .. note:: If both this and ``sigpipe`` set to ``False``, it's the same as setting ``write-errors-exception-only`` uWSGI option. :param int write_errors_tolerance: Set the maximum number of allowed write errors before exception is raised. Default: no tolerance. .. note:: Available for Python, Perl, PHP. :param bool sigpipe: Log (annoying) SIGPIPE. Default: ``True``. .. note:: If both this and ``write_errors`` set to ``False``, it's the same as setting ``write-errors-exception-only`` uWSGI option.
f13039:c3:m3
def set_requests_filters(<EOL>self, slower=None, bigger=None, status_4xx=None, status_5xx=None,<EOL>no_body=None, sendfile=None, io_errors=None):
self._set('<STR_LIT>', slower)<EOL>self._set('<STR_LIT>', bigger)<EOL>self._set('<STR_LIT>', status_4xx, cast=bool)<EOL>self._set('<STR_LIT>', status_5xx, cast=bool)<EOL>self._set('<STR_LIT>', no_body, cast=bool)<EOL>self._set('<STR_LIT>', sendfile, cast=bool)<EOL>self._set('<STR_LIT>', io_errors, cast=bool)<EOL>return self._section<EOL>
Set various log data filters. :param int slower: Log requests slower than the specified number of milliseconds. :param int bigger: Log requests bigger than the specified size in bytes. :param status_4xx: Log requests with a 4xx response. :param status_5xx: Log requests with a 5xx response. :param bool no_body: Log responses without body. :param bool sendfile: Log sendfile requests. :param bool io_errors: Log requests with io errors.
f13039:c3:m4
def set_master_logging_params(<EOL>self, enable=None, dedicate_thread=None, buffer=None,<EOL>sock_stream=None, sock_stream_requests_only=None):
self._set('<STR_LIT>', enable, cast=bool)<EOL>self._set('<STR_LIT>', dedicate_thread, cast=bool)<EOL>self._set('<STR_LIT>', buffer)<EOL>self._set('<STR_LIT>', sock_stream, cast=bool)<EOL>if sock_stream_requests_only:<EOL><INDENT>self._set('<STR_LIT>', sock_stream_requests_only, cast=bool)<EOL><DEDENT>return self._section<EOL>
Sets logging params for delegating logging to master process. :param bool enable: Delegate logging to master process. Delegate the write of the logs to the master process (this will put all of the logging I/O to a single process). Useful for system with advanced I/O schedulers/elevators. :param bool dedicate_thread: Delegate log writing to a thread. As error situations could cause the master to block while writing a log line to a remote server, it may be a good idea to use this option and delegate writes to a secondary thread. :param int buffer: Set the buffer size for the master logger in bytes. Bigger log messages will be truncated. :param bool|tuple sock_stream: Create the master logpipe as SOCK_STREAM. :param bool|tuple sock_stream_requests_only: Create the master requests logpipe as SOCK_STREAM.
f13039:c3:m5
def print_loggers(self):
self._set('<STR_LIT>', True, cast=bool)<EOL>return self._section<EOL>
Print out available (built) loggers.
f13039:c3:m6
def add_logger(self, logger, requests_only=False, for_single_worker=False):
if for_single_worker:<EOL><INDENT>command = '<STR_LIT>' if requests_only else '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>command = '<STR_LIT>' if requests_only else '<STR_LIT>'<EOL><DEDENT>for logger in listify(logger):<EOL><INDENT>self._set(command, logger, multi=True)<EOL><DEDENT>return self._section<EOL>
Set/add a common logger or a request requests only. :param str|unicode|list|Logger|list[Logger] logger: :param bool requests_only: Logger used only for requests information messages. :param bool for_single_worker: Logger to be used in single-worker setup.
f13039:c3:m7
def add_logger_route(self, logger, matcher, requests_only=False):
command = '<STR_LIT>' if requests_only else '<STR_LIT>'<EOL>for logger in listify(logger):<EOL><INDENT>self._set(command, '<STR_LIT>' % (logger, matcher), multi=True)<EOL><DEDENT>return self._section<EOL>
Log to the specified named logger if regexp applied on log item matches. :param str|unicode|list|Logger|list[Logger] logger: Logger to associate route with. :param str|unicode matcher: Regular expression to apply to log item. :param bool requests_only: Matching should be used only for requests information messages.
f13039:c3:m8
def add_logger_encoder(self, encoder, logger=None, requests_only=False, for_single_worker=False):
if for_single_worker:<EOL><INDENT>command = '<STR_LIT>' if requests_only else '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>command = '<STR_LIT>' if requests_only else '<STR_LIT>'<EOL><DEDENT>for encoder in listify(encoder):<EOL><INDENT>value = '<STR_LIT:%s>' % encoder<EOL>if logger:<EOL><INDENT>if isinstance(logger, Logger):<EOL><INDENT>logger = logger.alias<EOL><DEDENT>value += '<STR_LIT>' % logger<EOL><DEDENT>self._set(command, value, multi=True)<EOL><DEDENT>return self._section<EOL>
Add an item in the log encoder or request encoder chain. * http://uwsgi-docs.readthedocs.io/en/latest/LogEncoders.html .. note:: Encoders automatically enable master log handling (see ``.set_master_logging_params()``). .. note:: For best performance consider allocating a thread for log sending with ``dedicate_thread``. :param str|unicode|list|Encoder encoder: Encoder (or a list) to add into processing. :param str|unicode|Logger logger: Logger apply associate encoders to. :param bool requests_only: Encoder to be used only for requests information messages. :param bool for_single_worker: Encoder to be used in single-worker setup.
f13039:c3:m9
def __init__(self, name, mule_numbers):
<EOL>self.name = name<EOL>self.mule_numbers = mule_numbers<EOL>
:param str|unicode name: Farm alias. :param int|list[int] mule_numbers: Total mules on farm count, or a list of mule numbers.
f13040:c0:m0
def set_basic_params(<EOL>self, count=None, touch_reload=None, touch_chain_reload=None, zombie_reaper=None,<EOL>limit_addr_space=None, limit_count=None, cpu_affinity=None):
<EOL>self.set_count_auto(count)<EOL>self._set('<STR_LIT>', touch_reload, multi=True)<EOL>self._set('<STR_LIT>', touch_chain_reload, multi=True)<EOL>self._set('<STR_LIT>', zombie_reaper, cast=bool)<EOL>self._set('<STR_LIT>', limit_addr_space)<EOL>self._set('<STR_LIT>', limit_count)<EOL>self._set('<STR_LIT>', cpu_affinity)<EOL>return self._section<EOL>
:param int count: Spawn the specified number of workers (processes). Set the number of workers for preforking mode. This is the base for easy and safe concurrency in your app. More workers you add, more concurrent requests you can manage. Each worker corresponds to a system process, so it consumes memory, choose carefully the right number. You can easily drop your system to its knees by setting a too high value. Setting ``workers`` to a ridiculously high number will **not** magically make your application web scale - quite the contrary. :param str|list touch_reload: Trigger reload of (and only) workers if the specified file is modified/touched. :param str|list touch_chain_reload: Trigger chain workers reload on file touch. When in lazy/lazy_apps mode, you can simply destroy a worker to force it to reload the application code. A new reloading system named "chain reload", allows you to reload one worker at time (opposed to the standard way where all of the workers are destroyed in bulk) * http://uwsgi-docs.readthedocs.io/en/latest/articles/TheArtOfGracefulReloading.html#chain-reloading-lazy-apps :param bool zombie_reaper: Call waitpid(-1,...) after each request to get rid of zombies. Enables reaper mode. After each request the server will call ``waitpid(-1)`` to get rid of zombie processes. If you spawn subprocesses in your app and you happen to end up with zombie processes all over the place you can enable this option. (It really would be better if you could fix your application's process spawning usage though.) :param int limit_addr_space: Limit process address space (vsz) (in megabytes) Limits the address space usage of each uWSGI (worker) process using POSIX/UNIX ``setrlimit()``. For example, ``limit-as 256`` will disallow uWSGI processes to grow over 256MB of address space. Address space is the virtual memory a process has access to. It does *not* correspond to physical memory. Read and understand this page before enabling this option: http://en.wikipedia.org/wiki/Virtual_memory :param int limit_count: Limit the number of spawnable processes. :param int cpu_affinity: number of cores for each worker (Linux only) Set the number of cores (CPUs) to allocate to each worker process. * 4 workers, 4 CPUs, affinity is 1, each worker is allocated one CPU. * 4 workers, 2 CPUs, affinity is 1, workers get one CPU each (0; 1; 0; 1). * 4 workers, 4 CPUs, affinity is 2, workers get two CPUs each in a round-robin fashion (0, 1; 2, 3; 0, 1; 2; 3). * 8 workers, 4 CPUs, affinity is 3, workers get three CPUs each in a round-robin fashion (0, 1, 2; 3, 0, 1; 2, 3, 0; 1, 2, 3; 0, 1, 2; 3, 0, 1; 2, 3, 0; 1, 2, 3).
f13040:c1:m0
def run_command_as_worker(self, command, after_post_fork_hook=False):
self._set('<STR_LIT>' if after_post_fork_hook else '<STR_LIT>', command, multi=True)<EOL>return self._section<EOL>
Run the specified command as worker. :param str|unicode command: :param bool after_post_fork_hook: Whether to run it after `post_fork` hook.
f13040:c1:m1
def set_count_auto(self, count=None):
count = count or self._section.vars.CPU_CORES<EOL>self._set('<STR_LIT>', count)<EOL>return self._section<EOL>
Sets workers count. By default sets it to detected number of available cores :param int count:
f13040:c1:m2
def set_thread_params(<EOL>self, enable=None, count=None, count_offload=None, stack_size=None, no_wait=None):
self._set('<STR_LIT>', enable, cast=bool)<EOL>self._set('<STR_LIT>', no_wait, cast=bool)<EOL>self._set('<STR_LIT>', count)<EOL>self._set('<STR_LIT>', count_offload)<EOL>if count:<EOL><INDENT>self._section.print_out('<STR_LIT>' % count)<EOL><DEDENT>self._set('<STR_LIT>', stack_size)<EOL>return self._section<EOL>
Sets threads related params. :param bool enable: Enable threads in the embedded languages. This will allow to spawn threads in your app. .. warning:: Threads will simply *not work* if this option is not enabled. There will likely be no error, just no execution of your thread code. :param int count: Run each worker in prethreaded mode with the specified number of threads per worker. .. warning:: Do not use with ``gevent``. .. note:: Enables threads automatically. :param int count_offload: Set the number of threads (per-worker) to spawn for offloading. Default: 0. These threads run such tasks in a non-blocking/evented way allowing for a huge amount of concurrency. Various components of the uWSGI stack are offload-friendly. .. note:: Try to set it to the number of CPU cores to take advantage of SMP. * http://uwsgi-docs.readthedocs.io/en/latest/OffloadSubsystem.html :param int stack_size: Set threads stacksize. :param bool no_wait: Do not wait for threads cancellation on quit/reload.
f13040:c1:m3
def set_mules_params(<EOL>self, mules=None, touch_reload=None, harakiri_timeout=None, farms=None, reload_mercy=None,<EOL>msg_buffer=None, msg_buffer_recv=None):
farms = farms or []<EOL>next_mule_number = <NUM_LIT:1><EOL>farm_mules_count = <NUM_LIT:0><EOL>for farm in farms:<EOL><INDENT>if isinstance(farm.mule_numbers, int):<EOL><INDENT>farm.mule_numbers = list(range(next_mule_number, next_mule_number + farm.mule_numbers))<EOL>next_mule_number = farm.mule_numbers[-<NUM_LIT:1>] + <NUM_LIT:1><EOL><DEDENT>farm_mules_count += len(farm.mule_numbers)<EOL>self._set('<STR_LIT>', farm, multi=True)<EOL><DEDENT>if mules is None and farm_mules_count:<EOL><INDENT>mules = farm_mules_count<EOL><DEDENT>if isinstance(mules, int):<EOL><INDENT>self._set('<STR_LIT>', mules)<EOL><DEDENT>elif isinstance(mules, list):<EOL><INDENT>for mule in mules:<EOL><INDENT>self._set('<STR_LIT>', mule, multi=True)<EOL><DEDENT><DEDENT>self._set('<STR_LIT>', touch_reload, multi=True)<EOL>self._set('<STR_LIT>', harakiri_timeout)<EOL>self._set('<STR_LIT>', reload_mercy)<EOL>self._set('<STR_LIT>', msg_buffer)<EOL>self._set('<STR_LIT>', msg_buffer_recv)<EOL>return self._section<EOL>
Sets mules related params. http://uwsgi.readthedocs.io/en/latest/Mules.html Mules are worker processes living in the uWSGI stack but not reachable via socket connections, that can be used as a generic subsystem to offload tasks. :param int|list mules: Add the specified mules or number of mules. :param str|list touch_reload: Reload mules if the specified file is modified/touched. :param int harakiri_timeout: Set harakiri timeout for mule tasks. :param list[MuleFarm] farms: Mule farms list. Examples: * cls_mule_farm('first', 2) * cls_mule_farm('first', [4, 5]) :param int reload_mercy: Set the maximum time (in seconds) a mule can take to reload/shutdown. Default: 60. :param int msg_buffer: Set mule message buffer size (bytes) given for mule message queue. :param int msg_buffer: Set mule message recv buffer size (bytes).
f13040:c1:m4
def set_reload_params(<EOL>self, min_lifetime=None, max_lifetime=None,<EOL>max_requests=None, max_requests_delta=None,<EOL>max_addr_space=None, max_rss=None, max_uss=None, max_pss=None,<EOL>max_addr_space_forced=None, max_rss_forced=None, watch_interval_forced=None,<EOL>mercy=None):
self._set('<STR_LIT>', max_requests)<EOL>self._set('<STR_LIT>', max_requests_delta)<EOL>self._set('<STR_LIT>', min_lifetime)<EOL>self._set('<STR_LIT>', max_lifetime)<EOL>self._set('<STR_LIT>', max_addr_space)<EOL>self._set('<STR_LIT>', max_rss)<EOL>self._set('<STR_LIT>', max_uss)<EOL>self._set('<STR_LIT>', max_pss)<EOL>self._set('<STR_LIT>', max_addr_space_forced)<EOL>self._set('<STR_LIT>', max_rss_forced)<EOL>self._set('<STR_LIT>', watch_interval_forced)<EOL>self._set('<STR_LIT>', mercy)<EOL>return self._section<EOL>
Sets workers reload parameters. :param int min_lifetime: A worker cannot be destroyed/reloaded unless it has been alive for N seconds (default 60). This is an anti-fork-bomb measure. Since 1.9 :param int max_lifetime: Reload workers after this many seconds. Disabled by default. Since 1.9 :param int max_requests: Reload workers after the specified amount of managed requests (avoid memory leaks). When a worker reaches this number of requests it will get recycled (killed and restarted). You can use this option to "dumb fight" memory leaks. Also take a look at the ``reload-on-as`` and ``reload-on-rss`` options as they are more useful for memory leaks. .. warning:: The default min-worker-lifetime 60 seconds takes priority over `max-requests`. Do not use with benchmarking as you'll get stalls such as `worker respawning too fast !!! i have to sleep a bit (2 seconds)...` :param int max_requests_delta: Add (worker_id * delta) to the max_requests value of each worker. :param int max_addr_space: Reload a worker if its address space usage is higher than the specified value in megabytes. :param int max_rss: Reload a worker if its physical unshared memory (resident set size) is higher than the specified value (in megabytes). :param int max_uss: Reload a worker if Unique Set Size is higher than the specified value in megabytes. .. note:: Linux only. :param int max_pss: Reload a worker if Proportional Set Size is higher than the specified value in megabytes. .. note:: Linux only. :param int max_addr_space_forced: Force the master to reload a worker if its address space is higher than specified megabytes (in megabytes). :param int max_rss_forced: Force the master to reload a worker if its resident set size memory is higher than specified in megabytes. :param int watch_interval_forced: The memory collector [per-worker] thread memeory watch interval (seconds) used for forced reloads. Default: 3. :param int mercy: Set the maximum time (in seconds) a worker can take before reload/shutdown. Default: 60.
f13040:c1:m5
def set_reload_on_exception_params(self, do_reload=None, etype=None, evalue=None, erepr=None):
self._set('<STR_LIT>', do_reload, cast=bool)<EOL>self._set('<STR_LIT>', etype)<EOL>self._set('<STR_LIT>', evalue)<EOL>self._set('<STR_LIT>', erepr)<EOL>return self._section<EOL>
Sets workers reload on exceptions parameters. :param bool do_reload: Reload a worker when an exception is raised. :param str etype: Reload a worker when a specific exception type is raised. :param str evalue: Reload a worker when a specific exception value is raised. :param str erepr: Reload a worker when a specific exception type+value (language-specific) is raised.
f13040:c1:m6
def set_harakiri_params(self, timeout=None, verbose=None, disable_for_arh=None):
self._set('<STR_LIT>', timeout)<EOL>self._set('<STR_LIT>', verbose, cast=bool)<EOL>self._set('<STR_LIT>', disable_for_arh, cast=bool)<EOL>return self._section<EOL>
Sets workers harakiri parameters. :param int timeout: Harakiri timeout in seconds. Every request that will take longer than the seconds specified in the harakiri timeout will be dropped and the corresponding worker is thereafter recycled. :param bool verbose: Harakiri verbose mode. When a request is killed by Harakiri you will get a message in the uWSGI log. Enabling this option will print additional info (for example, the current syscall will be reported on Linux platforms). :param bool disable_for_arh: Disallow Harakiri killings during after-request hook methods.
f13040:c1:m7
def set_zerg_server_params(self, socket, clients_socket_pool=None):
if clients_socket_pool:<EOL><INDENT>self._set('<STR_LIT>', '<STR_LIT>' % (socket, '<STR_LIT:U+002C>'.join(listify(clients_socket_pool))), multi=True)<EOL><DEDENT>else:<EOL><INDENT>self._set('<STR_LIT>', socket)<EOL><DEDENT>return self._section<EOL>
Zerg mode. Zerg server params. When your site load is variable, it would be nice to be able to add workers dynamically. Enabling Zerg mode you can allow zerg clients to attach to your already running server and help it in the work. * http://uwsgi-docs.readthedocs.io/en/latest/Zerg.html :param str|unicode socket: Unix socket to bind server to. Examples: * unix socket - ``/var/run/mutalisk`` * Linux abstract namespace - ``@nydus`` :param str|unicode|list[str|unicode] clients_socket_pool: This enables Zerg Pools. .. note:: Expects master process. Accepts sockets that will be mapped to Zerg socket. * http://uwsgi-docs.readthedocs.io/en/latest/Zerg.html#zerg-pools
f13040:c1:m8
def set_zerg_client_params(self, server_sockets, use_fallback_socket=None):
self._set('<STR_LIT>', server_sockets, multi=True)<EOL>if use_fallback_socket is not None:<EOL><INDENT>self._set('<STR_LIT>', use_fallback_socket, cast=bool)<EOL>for socket in listify(server_sockets):<EOL><INDENT>self._section.networking.register_socket(self._section.networking.sockets.default(socket))<EOL><DEDENT><DEDENT>return self._section<EOL>
Zerg mode. Zergs params. :param str|unicode|list[str|unicode] server_sockets: Attaches zerg to a zerg server. :param bool use_fallback_socket: Fallback to normal sockets if the zerg server is not available
f13040:c1:m9
def __init__(self, action, subject=subjects.path_info('<STR_LIT>'), stage=stages.REQUEST):
if subject is None:<EOL><INDENT>subject = '<STR_LIT>' <EOL><DEDENT>subject_rule = '<STR_LIT>'<EOL>self._custom_subject = isinstance(subject, SubjectCustom)<EOL>if self._custom_subject:<EOL><INDENT>subject_rule = subject<EOL>subject = '<STR_LIT>' if subject.negate else '<STR_LIT>'<EOL><DEDENT>elif isinstance(subject, SubjectBuiltin):<EOL><INDENT>subject_rule = subject.regexp<EOL>subject = subject.name<EOL><DEDENT>self.command_label = ('<STR_LIT>' % stage).strip('<STR_LIT:->')<EOL>self.command = ('<STR_LIT>' % (stage, subject)).strip('<STR_LIT:->')<EOL>self.value = subject_rule, action<EOL>
:param RouteAction action: Action (or transformation) to perfrom. See ``.actions`` and ``.transforms``. :param SubjectCustom|SubjectBuiltin subject: Subject to verify before action is performed. See ``.subjects``. :param str|unicode stage: Stage on which the action needs to be performed. See ``.stages``.
f13041:c0:m0
def use_router(self, router, force=None):
self._set('<STR_LIT>', force, cast=bool)<EOL>router._contribute_to_opts(self)<EOL>return self._section<EOL>
:param RouterBase router: Dedicated router object. See `.routers`. :param bool force: All of the gateways (routers) has to be run under the master process, supplying this you can try to bypass this limit.
f13041:c1:m0
def register_route(self, route_rules, label=None):
route_rules = listify(route_rules)<EOL>if route_rules and label:<EOL><INDENT>self._set(route_rules[<NUM_LIT:0>].command_label, label, multi=True)<EOL><DEDENT>for route_rules in route_rules:<EOL><INDENT>self._set(route_rules.command, route_rules.value, multi=True)<EOL><DEDENT>return self._section<EOL>
Registers a routing rule. :param RouteRule|list[RouteRule] route_rules: :param str|unicode label: Label to mark the given set of rules. This can be used in conjunction with ``do_goto`` rule action. * http://uwsgi.readthedocs.io/en/latest/InternalRouting.html#goto
f13041:c1:m1
def print_routing_rules(self):
self._set('<STR_LIT>', True, cast=bool)<EOL>return self._section<EOL>
Print out supported routing rules (actions, transforms, etc.).
f13041:c1:m2
def set_error_page(self, status, html_fpath):
statuses = [<NUM_LIT>, <NUM_LIT>, <NUM_LIT>]<EOL>status = int(status)<EOL>if status not in statuses:<EOL><INDENT>raise ConfigurationError(<EOL>'<STR_LIT>' %<EOL>(status, '<STR_LIT:U+002CU+0020>'.join(map(str, statuses))))<EOL><DEDENT>self._set('<STR_LIT>' % status, html_fpath, multi=True)<EOL>return self._section<EOL>
Add an error page (html) for managed 403, 404, 500 response. :param int status: HTTP status code. :param str|unicode html_fpath: HTML page file path.
f13041:c1:m3
def set_error_pages(self, codes_map=None, common_prefix=None):
statuses = [<NUM_LIT>, <NUM_LIT>, <NUM_LIT>]<EOL>if common_prefix:<EOL><INDENT>if not codes_map:<EOL><INDENT>codes_map = {code: '<STR_LIT>' % code for code in statuses}<EOL><DEDENT>for code, filename in codes_map.items():<EOL><INDENT>codes_map[code] = os.path.join(common_prefix, filename)<EOL><DEDENT><DEDENT>for code, filepath in codes_map.items():<EOL><INDENT>self.set_error_page(code, filepath)<EOL><DEDENT>return self._section<EOL>
Add an error pages for managed 403, 404, 500 responses. Shortcut for ``.set_error_page()``. :param dict codes_map: Status code mapped into an html filepath or just a filename if common_prefix is used. If not set, filename containing status code is presumed: 400.html, 500.html, etc. :param str|unicode common_prefix: Common path (prefix) for all files.
f13041:c1:m4
def set_geoip_params(self, db_country=None, db_city=None):
self._set('<STR_LIT>', db_country, plugin='<STR_LIT>')<EOL>self._set('<STR_LIT>', db_city, plugin='<STR_LIT>')<EOL>return self._section<EOL>
Sets GeoIP parameters. * http://uwsgi.readthedocs.io/en/latest/GeoIP.html :param str|unicode db_country: Country database file path. :param str|unicode db_city: City database file path. Example: ``GeoLiteCity.dat``.
f13041:c1:m5
def header_add(self, name, value):
self._set('<STR_LIT>', '<STR_LIT>' % (name, value), multi=True)<EOL>return self._section<EOL>
Automatically add HTTP headers to response. :param str|unicode name: :param str|unicode value:
f13041:c1:m6
def header_remove(self, value):
self._set('<STR_LIT>', value, multi=True)<EOL>return self._section<EOL>
Automatically remove specified HTTP header from the response. :param str|unicode value:
f13041:c1:m7
def header_collect(self, name, target_var, pull=False):
self._set(<EOL>'<STR_LIT>' if pull else '<STR_LIT>',<EOL>'<STR_LIT>' % (name, target_var), multi=True)<EOL>return self._section<EOL>
Store the specified response header in a request var (optionally removing it from the response). :param str|unicode name: :param str|unicode target_var: :param bool pull: Whether to remove header from response.
f13041:c1:m8
def enable(self, size, block_size=None, store=None, store_sync_interval=None):
self._set('<STR_LIT>', size)<EOL>self._set('<STR_LIT>', block_size)<EOL>self._set('<STR_LIT>', store)<EOL>self._set('<STR_LIT>', store_sync_interval)<EOL>return self._section<EOL>
Enables shared queue of the given size. :param int size: Queue size. :param int block_size: Block size in bytes. Default: 8 KiB. :param str|unicode store: Persist the queue into file. :param int store_sync_interval: Store sync interval in master cycles (usually seconds).
f13042:c0:m0
def set_server_params(<EOL>self, client_notify_address=None, mountpoints_depth=None, require_vassal=None,<EOL>tolerance=None, tolerance_inactive=None, key_dot_split=None):
<EOL>self._set('<STR_LIT>', client_notify_address)<EOL>self._set('<STR_LIT>', mountpoints_depth)<EOL>self._set('<STR_LIT>', require_vassal, cast=bool)<EOL>self._set('<STR_LIT>', tolerance)<EOL>self._set('<STR_LIT>', tolerance_inactive)<EOL>self._set('<STR_LIT>', key_dot_split, cast=bool)<EOL>return self._section<EOL>
Sets subscription server related params. :param str|unicode client_notify_address: Set the notification socket for subscriptions. When you subscribe to a server, you can ask it to "acknowledge" the acceptance of your request. pointing address (Unix socket or UDP), on which your instance will bind and the subscription server will send acknowledgements to. :param int mountpoints_depth: Enable support of mountpoints of certain depth for subscription system. * http://uwsgi-docs.readthedocs.io/en/latest/SubscriptionServer.html#mountpoints-uwsgi-2-1 :param bool require_vassal: Require a vassal field (see ``subscribe``) from each subscription. :param int tolerance: Subscription reclaim tolerance (seconds). :param int tolerance_inactive: Subscription inactivity tolerance (seconds). :param bool key_dot_split: Try to fallback to the next part in (dot based) subscription key. Used, for example, in SNI.
f13043:c0:m0
def set_server_verification_params(<EOL>self, digest_algo=None, dir_cert=None, tolerance=None, no_check_uid=None,<EOL>dir_credentials=None, pass_unix_credentials=None):
if digest_algo and dir_cert:<EOL><INDENT>self._set('<STR_LIT>', '<STR_LIT>' % (digest_algo, dir_cert))<EOL><DEDENT>self._set('<STR_LIT>', tolerance)<EOL>self._set('<STR_LIT>', no_check_uid, multi=True)<EOL>self._set('<STR_LIT>', dir_credentials, multi=True)<EOL>self._set('<STR_LIT>', pass_unix_credentials, cast=bool)<EOL>return self._section<EOL>
Sets peer verification params for subscription server. These are for secured subscriptions. :param str|unicode digest_algo: Digest algorithm. Example: SHA1 .. note:: Also requires ``dir_cert`` to be set. :param str|unicode dir_cert: Certificate directory. .. note:: Also requires ``digest_algo`` to be set. :param int tolerance: Maximum tolerance (in seconds) of clock skew for secured subscription system. Default: 24h. :param str|unicode|int|list[str|unicode|int] no_check_uid: Skip signature check for the specified uids when using unix sockets credentials. :param str|unicode|list[str|unicode] dir_credentials: Directories to search for subscriptions key credentials. :param bool pass_unix_credentials: Enable management of SCM_CREDENTIALS in subscriptions UNIX sockets.
f13043:c0:m1
def set_client_params(<EOL>self, start_unsubscribed=None, clear_on_exit=None, unsubscribe_on_reload=None,<EOL>announce_interval=None):
self._set('<STR_LIT>', start_unsubscribed, cast=bool)<EOL>self._set('<STR_LIT>', clear_on_exit, cast=bool)<EOL>self._set('<STR_LIT>', unsubscribe_on_reload, cast=bool)<EOL>self._set('<STR_LIT>', announce_interval)<EOL>return self._section<EOL>
Sets subscribers related params. :param bool start_unsubscribed: Configure subscriptions but do not send them. .. note:: Useful with master FIFO. :param bool clear_on_exit: Force clear instead of unsubscribe during shutdown. :param bool unsubscribe_on_reload: Force unsubscribe request even during graceful reload. :param int announce_interval: Send subscription announce at the specified interval. Default: 10 master cycles.
f13043:c0:m2
def subscribe(<EOL>self, server=None, key=None, address=None, address_vassal=None,<EOL>balancing_weight=None, balancing_algo=None, modifier=None, signing=None, check_file=None, protocol=None,<EOL>sni_cert=None, sni_key=None, sni_client_ca=None):
<EOL>if not any((server, key)):<EOL><INDENT>raise ConfigurationError('<STR_LIT>')<EOL><DEDENT>address_key = '<STR_LIT>'<EOL>if isinstance(address, int):<EOL><INDENT>address_key = '<STR_LIT>'<EOL><DEDENT>if balancing_algo:<EOL><INDENT>backup = getattr(balancing_algo, '<STR_LIT>', None)<EOL><DEDENT>if signing:<EOL><INDENT>signing = '<STR_LIT::>'.join(signing)<EOL><DEDENT>if modifier:<EOL><INDENT>modifier1 = modifier<EOL>if modifier.submod:<EOL><INDENT>modifier2 = modifier.submod<EOL><DEDENT><DEDENT>rule = KeyValue(<EOL>filter_locals(locals(), drop=['<STR_LIT>', '<STR_LIT>']),<EOL>aliases={<EOL>'<STR_LIT:address>': address_key,<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>},<EOL>)<EOL>self._set('<STR_LIT>', rule)<EOL>return self._section<EOL>
Registers a subscription intent. :param str|unicode server: Subscription server address (UDP or UNIX socket). Examples: * 127.0.0.1:7171 :param str|unicode key: Key to subscribe. Generally the domain name (+ optional '/< mountpoint>'). Examples: * mydomain.it/foo * mydomain.it/foo/bar (requires ``mountpoints_depth=2``) * mydomain.it * ubuntu64.local:9090 :param str|unicode|int address: Address to subscribe (the value for the key) or zero-based internal socket number (integer). :param str|unicode address: Vassal node address. :param int balancing_weight: Load balancing value. Default: 1. :param balancing_algo: Load balancing algorithm to use. See ``balancing_algorithms`` .. note:: Since 2.1 :param Modifier modifier: Routing modifier object. See ``.routing.modifiers`` :param list|tuple signing: Signing basics, expects two elements list/tuple: (signing_algorithm, key). Examples: * SHA1:idlessh001 :param str|unicode check_file: If this file exists the subscription packet is sent, otherwise it is skipped. :param str|unicode protocol: the protocol to use, by default it is ``uwsgi``. See ``.networking.socket_types``. .. note:: Since 2.1 :param str|unicode sni_cert: Certificate file to use for SNI proxy management. * http://uwsgi.readthedocs.io/en/latest/SNI.html#subscription-system-and-sni :param str|unicode sni_key: sni_key Key file to use for SNI proxy management. * http://uwsgi.readthedocs.io/en/latest/SNI.html#subscription-system-and-sni :param str|unicode sni_client_ca: Ca file to use for SNI proxy management. * http://uwsgi.readthedocs.io/en/latest/SNI.html#subscription-system-and-sni
f13043:c0:m3
def __init__(self, filepath, alias=None):
super(LoggerFile, self).__init__(alias, filepath)<EOL>
:param str|unicode filepath: File path. :param str|unicode alias: Logger alias.
f13044:c1:m0
def __init__(self, addr_or_path, alias=None):
super(LoggerSocket, self).__init__(alias, addr_or_path)<EOL>
:param str|unicode addr_or_path: Remote address or filepath. Examples: * /tmp/uwsgi.logsock * 192.168.173.19:5050 :param str|unicode alias: Logger alias.
f13044:c2:m0
def __init__(self, app_name=None, facility=None, alias=None):
super(LoggerSyslog, self).__init__(alias, app_name, facility)<EOL>
:param str|unicode app_name: :param str|unicode facility: * https://en.wikipedia.org/wiki/Syslog#Facility :param str|unicode alias: Logger alias.
f13044:c3:m0
def __init__(self, app_name=None, host=None, facility=None, split=None, packet_size=None, alias=None):
super(LoggerRsyslog, self).__init__(app_name, facility, alias=alias)<EOL>self.args.insert(<NUM_LIT:0>, host)<EOL>self._set('<STR_LIT>', packet_size)<EOL>self._set('<STR_LIT>', split, cast=bool)<EOL>
:param str|unicode app_name: :param str|unicode host: Address (host and port) or UNIX socket path. :param str|unicode facility: * https://en.wikipedia.org/wiki/Syslog#Facility :param bool split: Split big messages into multiple chunks if they are bigger than allowed packet size. Default: ``False``. :param int packet_size: Set maximum packet size for syslog messages. Default: 1024. .. warning:: using packets > 1024 breaks RFC 3164 (#4.1) :param str|unicode alias: Logger alias.
f13044:c4:m0
def __init__(self, host=None, command=None, prefix=None, alias=None):
super(LoggerRedis, self).__init__(alias, host, command, prefix)<EOL>
:param str|unicode host: Default: 127.0.0.1:6379 :param str|unicode command: Command to be used. Default: publish uwsgi Examples: * publish foobar * rpush foo :param str|unicode prefix: Default: <empty> :param str|unicode alias: Logger alias.
f13044:c5:m0
def __init__(self, host=None, collection=None, node=None, alias=None):
super(LoggerMongo, self).__init__(alias, host, collection, node)<EOL>
:param str|unicode host: Default: 127.0.0.1:27017 :param str|unicode collection: Command to be used. Default: uwsgi.logs :param str|unicode node: An identification string for the instance sending logs Default: <server hostname> :param str|unicode alias: Logger alias.
f13044:c6:m0
def __init__(self, connection_str, alias=None):
super(LoggerZeroMq, self).__init__(alias, connection_str)<EOL>
:param str|unicode connection_str: Examples: * tcp://192.168.173.18:9191 :param str|unicode alias: Logger alias.
f13044:c7:m0
def set_emperor_params(<EOL>self, vassals_home=None, name=None, scan_interval=None, pid_file=None, spawn_asap=None,<EOL>stats_address=None, trigger_socket=None, links_no_follow=None):
self._set('<STR_LIT>', vassals_home, multi=True)<EOL>self._set('<STR_LIT>', name)<EOL>self._set('<STR_LIT>', scan_interval)<EOL>self._set('<STR_LIT>', pid_file)<EOL>self._set('<STR_LIT>', spawn_asap, cast=bool)<EOL>self._set('<STR_LIT>', stats_address)<EOL>self._set('<STR_LIT>', trigger_socket)<EOL>self._set('<STR_LIT>', links_no_follow)<EOL>return self._section<EOL>
.. note:: The emperor should generally not be run with master, unless master features like advanced logging are specifically needed. .. note:: The emperor should generally be started at server boot time and left alone, not reloaded/restarted except for uWSGI upgrades; emperor reloads are a bit drastic, reloading all vassals at once. Instead vassals should be reloaded individually when needed, in the manner of the imperial monitor in use. :param str|unicode|list[str|unicode] vassals_home: Set vassals home and enable Emperor mode. :param str|unicode name: Set the Emperor process name. :param int scan_interval: Set the Emperor scan frequency. Default: 3 seconds. :param str|unicode pid_file: Write the Emperor pid in the specified file. :param bool spawn_asap: Spawn the Emperor as soon as possible. :param str|unicode stats_address: Run the Emperor stats server on specified address. :param str|unicode trigger_socket: Enable the Emperor trigger socket. :param bool links_no_follow: Do not follow symlinks when checking for mtime.
f13045:c0:m0
def print_monitors(self):
self._set('<STR_LIT>', True, cast=bool)<EOL>return self._section<EOL>
Print out enabled imperial monitors.
f13045:c0:m1
def set_emperor_command_params(<EOL>self, command_socket=None,<EOL>wait_for_command=None, wait_for_command_exclude=None):
self._set('<STR_LIT>', command_socket)<EOL>self._set('<STR_LIT>', wait_for_command, cast=bool)<EOL>self._set('<STR_LIT>', wait_for_command_exclude, multi=True)<EOL>return self._section<EOL>
Emperor commands related parameters. * http://uwsgi-docs.readthedocs.io/en/latest/tutorials/EmperorSubscriptions.html :param str|unicode command_socket: Enable the Emperor command socket. It is a channel allowing external process to govern vassals. :param bool wait_for_command: Always wait for a 'spawn' Emperor command before starting a vassal. :param str|unicode|list[str|unicode] wait_for_command_exclude: Vassals that will ignore ``wait_for_command``.
f13045:c0:m2
def set_vassals_wrapper_params(self, wrapper=None, overrides=None, fallbacks=None):
self._set('<STR_LIT>', wrapper)<EOL>self._set('<STR_LIT>', overrides, multi=True)<EOL>self._set('<STR_LIT>', fallbacks, multi=True)<EOL>return self._section<EOL>
Binary wrapper for vassals parameters. :param str|unicode wrapper: Set a binary wrapper for vassals. :param str|unicode|list[str|unicode] overrides: Set a binary wrapper for vassals to try before the default one :param str|unicode|list[str|unicode] fallbacks: Set a binary wrapper for vassals to try as a last resort. Allows you to specify an alternative binary to execute when running a vassal and the default binary_path is not found (or returns an error).
f13045:c0:m3
def set_throttle_params(self, level=None, level_max=None):
self._set('<STR_LIT>', level)<EOL>self._set('<STR_LIT>', level_max)<EOL>return self._section<EOL>
Throttling options. * http://uwsgi-docs.readthedocs.io/en/latest/Emperor.html#throttling * http://uwsgi-docs.readthedocs.io/en/latest/Emperor.html#loyalty :param int level: Set throttling level (in milliseconds) for bad behaving vassals. Default: 1000. :param int level_max: Set maximum throttling level (in milliseconds) for bad behaving vassals. Default: 3 minutes.
f13045:c0:m4
def set_tolerance_params(self, for_heartbeat=None, for_cursed_vassals=None):
self._set('<STR_LIT>', for_heartbeat)<EOL>self._set('<STR_LIT>', for_cursed_vassals)<EOL>return self._section<EOL>
Various tolerance options. :param int for_heartbeat: Set the Emperor tolerance about heartbeats. * http://uwsgi-docs.readthedocs.io/en/latest/Emperor.html#heartbeat-system :param int for_cursed_vassals: Set the Emperor tolerance about cursed vassals. * http://uwsgi-docs.readthedocs.io/en/latest/Emperor.html#blacklist-system
f13045:c0:m5
def set_mode_tyrant_params(self, enable=None, links_no_follow=None, use_initgroups=None):
self._set('<STR_LIT>', enable, cast=bool)<EOL>self._set('<STR_LIT>', links_no_follow, cast=bool)<EOL>self._set('<STR_LIT>', use_initgroups, cast=bool)<EOL>return self._section<EOL>
Tyrant mode (secure multi-user hosting). In Tyrant mode the Emperor will run the vassal using the UID/GID of the vassal configuration file. * http://uwsgi-docs.readthedocs.io/en/latest/Emperor.html#tyrant-mode-secure-multi-user-hosting :param enable: Puts the Emperor in Tyrant mode. :param bool links_no_follow: Do not follow symlinks when checking for uid/gid in Tyrant mode. :param bool use_initgroups: Add additional groups set via initgroups() in Tyrant mode.
f13045:c0:m6
def set_mode_broodlord_params(<EOL>self, zerg_count=None,<EOL>vassal_overload_sos_interval=None, vassal_queue_items_sos=None):
self._set('<STR_LIT>', zerg_count)<EOL>self._set('<STR_LIT>', vassal_overload_sos_interval)<EOL>self._set('<STR_LIT>', vassal_queue_items_sos)<EOL>return self._section<EOL>
This mode is a way for a vassal to ask for reinforcements to the Emperor. Reinforcements are new vassals spawned on demand generally bound on the same socket. .. warning:: If you are looking for a way to dynamically adapt the number of workers of an instance, check the Cheaper subsystem - adaptive process spawning mode. *Broodlord mode is for spawning totally new instances.* :param int zerg_count: Maximum number of zergs to spawn. :param int vassal_overload_sos_interval: Ask emperor for reinforcement when overloaded. Accepts the number of seconds to wait between asking for a new reinforcements. :param int vassal_queue_items_sos: Ask emperor for sos if listen queue (backlog) has more items than the value specified
f13045:c0:m7
def set_basic_params(self, check_interval_overload=None):
self._set('<STR_LIT>', check_interval_overload)<EOL>return self<EOL>
:param int check_interval_overload: Interval (sec) to wait after all workers are busy before new worker spawn.
f13046:c1:m0
def set_basic_params(self, check_interval_idle=None):
self._set('<STR_LIT>', check_interval_idle)<EOL>return self<EOL>
:param int check_interval_idle: Decrease workers after specified idle. Default: 10.
f13046:c2:m0
def set_basic_params(self, check_num_overload=None):
self._set('<STR_LIT>', check_num_overload)<EOL>return self._section<EOL>
:param int check_num_overload: Number of backlog items in queue.
f13046:c3:m0
def set_basic_params(<EOL>self, check_interval_busy=None,<EOL>busy_max=None, busy_min=None,<EOL>idle_cycles_max=None, idle_cycles_penalty=None,<EOL>verbose=None):
self._set('<STR_LIT>', check_interval_busy)<EOL>self._set('<STR_LIT>', busy_max)<EOL>self._set('<STR_LIT>', busy_min)<EOL>self._set('<STR_LIT>', idle_cycles_max)<EOL>self._set('<STR_LIT>', idle_cycles_penalty)<EOL>self._set('<STR_LIT>', verbose, cast=bool)<EOL>return self._section<EOL>
:param int check_interval_busy: Interval (sec) to check worker busyness. :param int busy_max: Maximum busyness (percents). Every time the calculated busyness is higher than this value, uWSGI will spawn new workers. Default: 50. :param int busy_min: Minimum busyness (percents). If busyness is below this value, the app is considered in an "idle cycle" and uWSGI will start counting them. Once we reach needed number of idle cycles uWSGI will kill one worker. Default: 25. :param int idle_cycles_max: This option tells uWSGI how many idle cycles are allowed before stopping a worker. :param int idle_cycles_penalty: Number of idle cycles to add to ``idle_cycles_max`` in case worker spawned too early. Default is 1. :param bool verbose: Enables debug logs for this algo.
f13046:c4:m0
def set_emergency_params(<EOL>self, workers_step=None, idle_cycles_max=None, queue_size=None, queue_nonzero_delay=None):
self._set('<STR_LIT>', workers_step)<EOL>self._set('<STR_LIT>', idle_cycles_max)<EOL>self._set('<STR_LIT>', queue_size)<EOL>self._set('<STR_LIT>', queue_nonzero_delay)<EOL>return self<EOL>
Sets busyness algorithm emergency workers related params. Emergency workers could be spawned depending upon uWSGI backlog state. .. note:: These options are Linux only. :param int workers_step: Number of emergency workers to spawn. Default: 1. :param int idle_cycles_max: Idle cycles to reach before stopping an emergency worker. Default: 3. :param int queue_size: Listen queue (backlog) max size to spawn an emergency worker. Default: 33. :param int queue_nonzero_delay: If the request listen queue is > 0 for more than given amount of seconds new emergency workers will be spawned. Default: 60.
f13046:c4:m1
def set_basic_params(<EOL>self, spawn_on_request=None,<EOL>cheaper_algo=None, workers_min=None, workers_startup=None, workers_step=None):
self._set('<STR_LIT>', spawn_on_request, cast=bool)<EOL>if cheaper_algo:<EOL><INDENT>self._set('<STR_LIT>', cheaper_algo.name)<EOL>if cheaper_algo.plugin:<EOL><INDENT>self._section.set_plugins_params(plugins=cheaper_algo.plugin)<EOL><DEDENT>cheaper_algo._contribute_to_opts(self)<EOL><DEDENT>self._set('<STR_LIT>', workers_min)<EOL>self._set('<STR_LIT>', workers_startup)<EOL>self._set('<STR_LIT>', workers_step)<EOL>return self._section<EOL>
:param bool spawn_on_request: Spawn workers only after the first request. :param Algo cheaper_algo: The algorithm object to be used used for adaptive process spawning. Default: ``spare``. See ``.algorithms``. :param int workers_min: Minimal workers count. Enables cheaper mode (adaptive process spawning). .. note:: Must be lower than max workers count. :param int workers_startup: The number of workers to be started when starting the application. After the app is started the algorithm can stop or start workers if needed. :param int workers_step: Number of additional processes to spawn at a time if they are needed,
f13046:c6:m0
def set_memory_limits(self, rss_soft=None, rss_hard=None):
self._set('<STR_LIT>', rss_soft) <EOL>self._set('<STR_LIT>', rss_hard)<EOL>return self._section<EOL>
Sets worker memory limits for cheapening. :param int rss_soft: Don't spawn new workers if total resident memory usage of all workers is higher than this limit in bytes. .. warning:: This option expects memory reporting enabled: ``.logging.set_basic_params(memory_report=1)`` :param int rss_hard: Try to stop workers if total workers resident memory usage is higher that thi limit in bytes.
f13046:c6:m1
def print_alorithms(self):
self._set('<STR_LIT>', True, cast=bool)<EOL>return self._section<EOL>
Print out enabled cheaper algorithms.
f13046:c6:m2
def __init__(self, value):
super(EncoderPrefix, self).__init__(value)<EOL>
:param str|unicode value: Value to be used as affix
f13047:c1:m0
def __init__(self, template):
super(EncoderFormat, self).__init__(template)<EOL>
:param str|unicode template: Template string. Available variables are listed in ``FormatEncoder.Vars``.
f13047:c6:m0
def __init__(self, fpath, get_slot=None):
value = KeyValue(locals(), aliases={'<STR_LIT>': '<STR_LIT>', '<STR_LIT>': '<STR_LIT>'})<EOL>super(CollectorFile, self).__init__(value)<EOL>
:param str|unicode fpath: File path. :param int get_slot: Get value from the given slot number. Slots: the content is split (using \\n, \\t, spaces, \\r and zero as separator) and the item (the returned array is zero-based) used as the return value.
f13048:c2:m0
def __init__(self, func):
value = KeyValue(locals(), aliases={'<STR_LIT>': '<STR_LIT>'})<EOL>super(CollectorFunction, self).__init__(value)<EOL>
:param str|unicode func: Function to call.
f13048:c3:m0
def __init__(self, what, value):
value = KeyValue(filter_locals(locals(), drop=['<STR_LIT>']), aliases={'<STR_LIT:value>': '<STR_LIT>'})<EOL>super(CollectorAdder, self).__init__(value, children=what)<EOL>
:param int value: Value to add (multiply if it is CollectorMultiplier).
f13048:c7:m0
def set_basic_params(<EOL>self, touch_reload=None, quiet=None, process_count=None, max_tasks=None,<EOL>order_tasks=None, harakiri=None, change_dir=None, poll_interval=None, signal_as_task=None,<EOL>cheap=None):
self._set('<STR_LIT>', touch_reload, multi=True)<EOL>self._set('<STR_LIT>', quiet, cast=bool)<EOL>self._set('<STR_LIT>', process_count)<EOL>self._set('<STR_LIT>', max_tasks)<EOL>self._set('<STR_LIT>', order_tasks, cast=bool)<EOL>self._set('<STR_LIT>', harakiri)<EOL>self._set('<STR_LIT>', change_dir)<EOL>self._set('<STR_LIT>', poll_interval)<EOL>self._set('<STR_LIT>', signal_as_task, cast=bool)<EOL>self._set('<STR_LIT>', cheap, cast=bool)<EOL>return self._section<EOL>
:param str|unicode|list touch_reload: reload spoolers if the specified file is modified/touched :param bool quiet: Do not log spooler related messages. :param int process_count: Set the number of processes for spoolers. :param int max_tasks: Set the maximum number of tasks to run before recycling a spooler (to help alleviate memory leaks). :param int order_tasks: Try to order the execution of spooler tasks (uses scandir instead of readdir). :param int harakiri: Set harakiri timeout for spooler tasks. :param str|unicode change_dir: chdir() to specified directory before each spooler task. :param int poll_interval: Spooler poll frequency in seconds. Default: 30. :param bool signal_as_task: Treat signal events as tasks in spooler, combine used with ``spooler-max-tasks``. Enable this, spooler will treat signal events as task. run signal handler will also increase the spooler task count. :param bool cheap: Use spooler cheap mode.
f13049:c0:m0
def add(self, work_dir, external=False):
command = '<STR_LIT>'<EOL>if external:<EOL><INDENT>command += '<STR_LIT>'<EOL><DEDENT>self._set(command, self._section.replace_placeholders(work_dir), multi=True)<EOL>return self._section<EOL>
Run a spooler on the specified directory. :param str|unicode work_dir: .. note:: Placeholders can be used to build paths, e.g.: {project_runtime_dir}/spool/ See ``Section.project_name`` and ``Section.runtime_dir``. :param bool external: map spoolers requests to a spooler directory managed by an external instance
f13049:c0:m1
def __init__(self, mountpoint, fs=None, src=None, flags=None):
if flags is not None:<EOL><INDENT>flags = listify(flags)<EOL>flags = '<STR_LIT:U+002C>'.join(flags)<EOL><DEDENT>if fs:<EOL><INDENT>args = [fs, src, mountpoint, flags]<EOL><DEDENT>else:<EOL><INDENT>args = [mountpoint, flags]<EOL>self.name = '<STR_LIT>'<EOL><DEDENT>super(ActionMount, self).__init__(*args)<EOL>
:param str|unicode mountpoint: :param str|unicode fs: Filesystem. Presence indicates mounting. :param str|unicode src: Presence indicates mounting. :param str|unicode|list flags: Flags available for the operating system. As an example on Linux you will options like: bind, recursive, readonly, rec, detach etc.
f13050:c1:m0
def __init__(self, target, honour_exit_status=False, arg_int=False):
name = self.name<EOL>if arg_int:<EOL><INDENT>name += '<STR_LIT:int>'<EOL><DEDENT>if honour_exit_status:<EOL><INDENT>name += '<STR_LIT>'<EOL><DEDENT>self.name = name<EOL>super(ActionCall, self).__init__(target)<EOL>
:param str|unicode target: Symbol and args. :param bool honour_exit_status: Expect an int return. Anything != 0 means failure. :param bool arg_int: Parse the argument as an int.
f13050:c3:m0
def __init__(self, target, text, append=False, newline=False):
if append:<EOL><INDENT>self.name = '<STR_LIT>'<EOL><DEDENT>if newline:<EOL><INDENT>self.name += '<STR_LIT:n>'<EOL><DEDENT>super(ActionFileWrite, self).__init__(target, text)<EOL>
:param str|unicode target: File to write to. :param str|unicode text: Text to write into file. :param bool append: Append text instead of rewrite. :param bool newline: Add a newline at the end.
f13050:c11:m0
def __init__(self, target, text, wait=False):
if wait:<EOL><INDENT>self.name = '<STR_LIT>'<EOL><DEDENT>super(ActionFifoWrite, self).__init__(target, text)<EOL>
:param bool wait: Wait until FIFO is available.
f13050:c12:m0
def __init__(self, add_header=False):
if add_header:<EOL><INDENT>self.name = '<STR_LIT>'<EOL><DEDENT>super(ActionFixContentLen, self).__init__()<EOL>
:param bool add_header: Force header add instead of plain fix of existing header.
f13051:c7:m0
def __init__(self, code, return_body=False):
if return_body:<EOL><INDENT>self.name = '<STR_LIT>'<EOL><DEDENT>super(ActionDoBreak, self).__init__(code)<EOL>
:param int code: HTTP code :param return_body: Uses uWSGI's built-in status code and returns both status code and message body.
f13051:c9:m0
def __init__(self, message):
if message is None:<EOL><INDENT>self.name = '<STR_LIT>'<EOL><DEDENT>super(ActionLog, self).__init__(message)<EOL>
:param str|unicode|None message: Message to add into log. If ``None`` logging will be disabled for this request.
f13051:c10:m0
def __init__(self, name, val):
super(ActionAddVarLog, self).__init__(name, val)<EOL>
:param str|unicode name: Variable name. :param val: Variable value.
f13051:c12:m0
def __init__(self, where):
super(ActionDoGoto, self).__init__(where)<EOL>
:param str|unicode|int where: Rule number of label to go to.
f13051:c13:m0
def __init__(self, name, val):
super(ActionAddVarCgi, self).__init__(name, val)<EOL>
:param str|unicode name: Variable name. :param val: Variable value.
f13051:c14:m0
def __init__(self, name, val):
name += '<STR_LIT::>'<EOL>super(ActionHeaderAdd, self).__init__(name, val)<EOL>
:param str|unicode name: Header name. :param val: Header value.
f13051:c15:m0
def __init__(self, name):
super(ActionHeaderRemove, self).__init__(name)<EOL>
:param str|unicode name: Header name.
f13051:c16:m0
def __init__(self, code):
super(ActionHeadersReset, self).__init__(code)<EOL>
:param int code: HTTP code.
f13051:c18:m0
def __init__(self, num):
super(ActionSignal, self).__init__(num)<EOL>
:param int num: Signal number.
f13051:c19:m0
def __init__(self, data, crnl=False):
if crnl:<EOL><INDENT>self.name = '<STR_LIT>'<EOL><DEDENT>super(ActionSend, self).__init__(data)<EOL>
:param data: Data to add to response. :param bool crnl: Add carriage return and new line.
f13051:c20:m0
def __init__(self, url, permanent=False):
if permanent:<EOL><INDENT>self.name = '<STR_LIT>'<EOL><DEDENT>super(ActionRedirect, self).__init__(url)<EOL>
:param str| unicode url: URL to redirect to. :param bool permanent: If ``True`` use 301, otherwise 302.
f13051:c21:m0
def __init__(self, rule, do_continue=False):
if do_continue:<EOL><INDENT>self.name = '<STR_LIT>'<EOL><DEDENT>super(ActionRewrite, self).__init__(rule)<EOL>
:param str|unicode rule: A rewrite rule. :param bool do_continue: Stop request processing and continue to the selected request handler.
f13051:c22:m0
def __init__(self, external_address='<STR_LIT>', modifier='<STR_LIT>', app='<STR_LIT>'):
super(ActionRouteUwsgi, self).__init__(external_address, modifier, modifier.submod, app)<EOL>
:param str|unicode external_address: External uWSGI server address (host:port). :param Modifier modifier: Set request modifier. :param str|unicode app: Set ``UWSGI_APPID``.
f13051:c23:m0
def __init__(self, address, host_header=None):
super(ActionRouteExternal, self).__init__(address, host_header)<EOL>
:param str|unicode address: External HTTP address (host:port) :param str|unicode host_header: HOST header value.
f13051:c24:m0
def __init__(self, name, message):
super(ActionAlarm, self).__init__(name, message)<EOL>
:param str|unicode name: Alarm name :param str|unicode message: Message to pass into alarm.
f13051:c25:m0
def __init__(self, fpath):
super(ActionServeStatic, self).__init__(fpath)<EOL>
:param str|unicode fpath: Static file path.
f13051:c26:m0
def __init__(self, realm, user=None, password=None, do_next=False):
if do_next:<EOL><INDENT>self.name = '<STR_LIT>'<EOL><DEDENT>user_password = []<EOL>if user:<EOL><INDENT>user += '<STR_LIT::>'<EOL>user_password.append(user)<EOL><DEDENT>if password:<EOL><INDENT>user_password.append(password)<EOL><DEDENT>super(ActionAuthBasic, self).__init__(realm, '<STR_LIT>'.join(user_password) if user_password else None)<EOL>
:param str|unicode realm: :param str|unicode user: :param str|unicode password: Password or htpasswd-like file. :param bool do_next: Allow next rule.
f13051:c27:m0
def __init__(<EOL>self, realm, address, base_dn=None, bind_dn=None, bind_password=None,<EOL>filter=None, login_attr=None, log_level=None,<EOL>do_next=False):
arg = KeyValue(<EOL>filter_locals(locals(), drop=['<STR_LIT>', '<STR_LIT>']),<EOL>aliases={<EOL>'<STR_LIT:address>': '<STR_LIT:url>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>},<EOL>items_separator='<STR_LIT:;>'<EOL>)<EOL>if do_next:<EOL><INDENT>self.name = '<STR_LIT>'<EOL><DEDENT>super(AuthLdap, self).__init__(realm, arg)<EOL>
:param str|unicode realm: :param str|unicode address: LDAP server URI :param str|unicode base_dn: Base DN used when searching for users. :param str|unicode bind_dn: DN used for binding. Required if the LDAP server does not allow anonymous searches. :param str|unicode bind_password: Password for the ``bind_dn`` user. :param str|unicode filter: Filter used when searching for users. Default: ``(objectClass=*)`` :param str|unicode login_attr: LDAP attribute that holds user login. Default: ``uid``. :param str|unicode log_level: Log level. Supported values: * 0 - don't log any binds * 1 - log authentication errors, * 2 - log both successful and failed binds :param bool do_next: Allow next rule.
f13051:c28:m0