Python uwsgi.worker_id() Examples
The following are 4
code examples of uwsgi.worker_id().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
uwsgi
, or try the search function
.
Example #1
Source File: utils.py From conifer with Apache License 2.0 | 6 votes |
def spawn_once(*args, **kwargs): worker_id = kwargs.pop('worker', None) mule_id = kwargs.pop('mule', 0) try: import uwsgi from uwsgidecorators import postfork @postfork def listen_loop(): if (mule_id is None or uwsgi.mule_id() == mule_id) and (worker_id is None or uwsgi.worker_id() == worker_id): gevent.spawn(*args, **kwargs) except: gevent.spawn(*args, **kwargs) # ============================================================================
Example #2
Source File: uwsgidecorators.py From jbox with MIT License | 5 votes |
def __call__(self, *args, **kwargs): if self.f: if self.wid > 0 and self.wid != uwsgi.worker_id(): return return self.f() self.f = args[0]
Example #3
Source File: uwsgidecorators.py From patzilla with GNU Affero General Public License v3.0 | 5 votes |
def __call__(self, *args, **kwargs): if self.f: if self.wid > 0 and self.wid != uwsgi.worker_id(): return return self.f() self.f = args[0]
Example #4
Source File: middleware.py From python-prometheus-demo with MIT License | 5 votes |
def _get_worker_id(): if use_uwsgi_worker_id: worker_id = uwsgi.worker_id() else: worker_id = os.getpid() return worker_id