当前位置: 首页>>代码示例>>Python>>正文


Python eventlet.getcurrent方法代码示例

本文整理汇总了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) 
开发者ID:datawire,项目名称:forge,代码行数:13,代码来源:executor.py

示例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 
开发者ID:ydf0509,项目名称:distributed_framework,代码行数:12,代码来源:base_consumer.py

示例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) 
开发者ID:openstack,项目名称:os-win,代码行数:15,代码来源:_utils.py

示例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] 
开发者ID:i2y,项目名称:mochi,代码行数:10,代码来源:actor.py

示例5: self

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import getcurrent [as 别名]
def self():
    cur_green = eventlet.getcurrent()
    return _actor_map.get(id(cur_green)) 
开发者ID:i2y,项目名称:mochi,代码行数:5,代码来源:actor.py


注:本文中的eventlet.getcurrent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。