-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs update on runtime configuration.
- Loading branch information
Showing
23 changed files
with
368 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Alarms | ||
====== | ||
|
||
.. automodule:: uwsgiconf.runtime.alarms | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Asynced | ||
======= | ||
|
||
.. automodule:: uwsgiconf.runtime.asynced | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Caching | ||
======= | ||
|
||
|
||
.. code-block:: python | ||
from uwsgiconf.runtime.caching import Cache | ||
# We'll access preconfigured cache named `mycache`. | ||
cache = Cache('mycache') | ||
key_exists = 'mykey' in cache | ||
def my_setter(key): | ||
if key == 'anotherkey': | ||
return 'yes' | ||
return 'no' | ||
# Getting cached value and populating it if required in one pass: | ||
yes_or_no = cache.get('anotherkey', setter=my_setter) | ||
.. automodule:: uwsgiconf.runtime.caching | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Control | ||
======= | ||
|
||
.. code-block:: python | ||
from uwsgiconf.runtime.control import harakiri_imposed, reload | ||
@harakiri_imposed(1) | ||
def doomed(): | ||
"""Master process will kill this function after 1 sec.""" | ||
# or | ||
with harakiri_imposed(30): | ||
# Master will kill worker if code under that manager won't finish in 30 sec. | ||
# We'll reload uWSGI. | ||
reload() | ||
.. automodule:: uwsgiconf.runtime.control | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Locking | ||
======= | ||
|
||
.. code-block:: python | ||
from uwsgiconf.runtime.locking import lock | ||
@lock() | ||
def locked(): | ||
"""This function will be locked with default (0) lock.""" | ||
... | ||
# or | ||
with lock(2): | ||
# Code under this context manager will be locked with lock 2. | ||
... | ||
.. automodule:: uwsgiconf.runtime.locking | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Logging | ||
======= | ||
|
||
|
||
.. automodule:: uwsgiconf.runtime.logging | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Monitoring | ||
========== | ||
|
||
|
||
.. automodule:: uwsgiconf.runtime.monitoring | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Mules | ||
===== | ||
|
||
.. code-block:: python | ||
from uwsgiconf.runtime.mules import Mule, Farm | ||
first_mule = Mule(1) | ||
@first_mule.offload() | ||
def for_mule(*args, **kwargs): | ||
# This function will be offloaded to and handled by mule 1. | ||
... | ||
farm_two = Farm('two') | ||
@farm_two.offload() | ||
def for_farm(*args, **kwargs): | ||
# And this one will be offloaded to farm `two` and handled by any mule from that farm. | ||
... | ||
.. automodule:: uwsgiconf.runtime.mules | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Platform | ||
======== | ||
|
||
Platform object is available in ``uwsgi`` module attribute: | ||
|
||
|
||
.. code-block:: python | ||
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!') | ||
.. autoclass:: uwsgiconf.runtime.platform._Platform | ||
:members: | ||
|
||
|
||
.. autoclass:: uwsgiconf.runtime.request._Request | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
RPC | ||
=== | ||
|
||
.. code-block:: python | ||
from uwsgiconf.runtime.rpc import register_rpc, make_rpc_call, get_rpc_list | ||
@register_rpc() | ||
def expose_me(arg1, arg2=15): | ||
print('RPC called %s' % arg1) | ||
make_rpc_call('expose_me', ['value1']) | ||
all_rpc = get_rpc_list() # Registered RPC items list. | ||
.. automodule:: uwsgiconf.runtime.rpc | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Scheduling | ||
========== | ||
|
||
.. code-block:: python | ||
from uwsgiconf.runtime.scheduling import register_timer_rb, register_cron | ||
@register_timer_rb(10, repeat=2) | ||
def repeat_twice(): | ||
"""This function will be called twice with 10 seconds interval | ||
(by default in in first available mule) using red-black tree based timer. | ||
""" | ||
@register_cron(day=-3, hour='10-18/2') | ||
def do_something(): | ||
"""This will be run every 3rd day, from 10 till 18 every 2 hours.""" | ||
.. automodule:: uwsgiconf.runtime.scheduling | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Signals | ||
======= | ||
|
||
.. automodule:: uwsgiconf.runtime.signals | ||
:members: |
Oops, something went wrong.