本文整理汇总了Python中eventlet.getcurrent方法的典型用法代码示例。如果您正苦于以下问题:Python eventlet.getcurrent方法的具体用法?Python eventlet.getcurrent怎么用?Python eventlet.getcurrent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eventlet
的用法示例。
在下文中一共展示了eventlet.getcurrent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wait
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import getcurrent [as 别名]
def wait(self):
if self.value is PENDING:
if self.thread not in (None, eventlet.getcurrent()):
self.thread.wait()
for ch in self.children:
ch.wait()
if self.child_errors > 0 and self.value is not ERROR:
errors = [e for e in self.leaf_errors if not e._recovered]
if errors:
self.value = ERROR
self.exception = (ChildError, ChildError(self, self.leaf_errors), None)
示例2: get_concurrent_info
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import getcurrent [as 别名]
def get_concurrent_info(cls):
concurrent_info = ''
if cls.global_concurrent_mode == 1:
concurrent_info = f'[{threading.current_thread()} {threading.active_count()}]'
elif cls.global_concurrent_mode == 2:
concurrent_info = f'[{gevent.getcurrent()} {threading.active_count()}]'
elif cls.global_concurrent_mode == 3:
# noinspection PyArgumentList
concurrent_info = f'[{eventlet.getcurrent()} {threading.active_count()}]'
return concurrent_info
示例3: avoid_blocking_call
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import getcurrent [as 别名]
def avoid_blocking_call(f, *args, **kwargs):
"""Ensures that the invoked method will not block other greenthreads.
Performs the call in a different thread using tpool.execute when called
from a greenthread.
"""
# Note that eventlet.getcurrent will always return a greenlet object.
# In case of a greenthread, the parent greenlet will always be the hub
# loop greenlet.
if eventlet.getcurrent().parent:
return tpool.execute(f, *args, **kwargs)
else:
return f(*args, **kwargs)
示例4: run
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import getcurrent [as 别名]
def run(self, *args, **kwargs):
greenlet_id = id(eventlet.getcurrent())
_actor_map[greenlet_id] = self
try:
self._callback(*args, **kwargs)
finally:
if greenlet_id in _actor_map.keys():
del _actor_map[greenlet_id]
示例5: self
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import getcurrent [as 别名]
def self():
cur_green = eventlet.getcurrent()
return _actor_map.get(id(cur_green))