本文整理匯總了Python中uwsgi.worker_id方法的典型用法代碼示例。如果您正苦於以下問題:Python uwsgi.worker_id方法的具體用法?Python uwsgi.worker_id怎麽用?Python uwsgi.worker_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類uwsgi
的用法示例。
在下文中一共展示了uwsgi.worker_id方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: spawn_once
# 需要導入模塊: import uwsgi [as 別名]
# 或者: from uwsgi import worker_id [as 別名]
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)
# ============================================================================
示例2: __call__
# 需要導入模塊: import uwsgi [as 別名]
# 或者: from uwsgi import worker_id [as 別名]
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]
示例3: _get_worker_id
# 需要導入模塊: import uwsgi [as 別名]
# 或者: from uwsgi import worker_id [as 別名]
def _get_worker_id():
if use_uwsgi_worker_id:
worker_id = uwsgi.worker_id()
else:
worker_id = os.getpid()
return worker_id