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


Python event.Event方法代码示例

本文整理汇总了Python中gevent.event.Event方法的典型用法代码示例。如果您正苦于以下问题:Python event.Event方法的具体用法?Python event.Event怎么用?Python event.Event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gevent.event的用法示例。


在下文中一共展示了event.Event方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from gevent import event [as 别名]
# 或者: from gevent.event import Event [as 别名]
def __init__(self, listener, handle=None, spawn='default'):
        self._stop_event = Event()
        self._stop_event.set()
        self._watcher = None
        self._timer = None
        self.pool = None
        try:
            self.set_listener(listener)
            self.set_spawn(spawn)
            self.set_handle(handle)
            self.delay = self.min_delay
            self.loop = get_hub().loop
            if self.max_accept < 1:
                raise ValueError('max_accept must be positive int: %r' % (self.max_accept, ))
        except:
            self.close()
            raise 
开发者ID:leancloud,项目名称:satori,代码行数:19,代码来源:baseserver.py

示例2: __new__

# 需要导入模块: from gevent import event [as 别名]
# 或者: from gevent.event import Event [as 别名]
def __new__(cls,
                tracer=None,
                local_pid=None,
                pause_signal=None,
                clients=None,
                both_sides_event=None,
                timestamp=None):
        clients = clients or set()
        both_sides_event = both_sides_event or Event()
        timestamp = timestamp or time()
        self = super(DebuggingSession, cls).__new__(
            cls,
            tracer,
            local_pid,
            pause_signal,
            clients,
            both_sides_event,
            timestamp,
        )
        return self 
开发者ID:quantopian,项目名称:qdb,代码行数:22,代码来源:session_store.py

示例3: pipe_socket

# 需要导入模块: from gevent import event [as 别名]
# 或者: from gevent.event import Event [as 别名]
def pipe_socket(client, remote):
    def copy(a, b, finish):
        while not finish.is_set():
            try:
                data = a.recv(CHUNKSIZE)
                if not data:
                    break
                b.sendall(data)
            except:
                break
        finish.set()
        
    finish = Event()
    finish.clear()
    threads = [
        gevent.spawn(copy, client, remote, finish),
        gevent.spawn(copy, remote, client, finish),
    ]
    [t.join() for t in threads]
    client.close()
    remote.close() 
开发者ID:yinghuocho,项目名称:ghttproxy,代码行数:23,代码来源:server.py

示例4: __init__

# 需要导入模块: from gevent import event [as 别名]
# 或者: from gevent.event import Event [as 别名]
def __init__(self, tree_hub, application_name, type_name, semaphore=None):
        assert type_name in ('service', 'switch', 'config')

        self.hub = tree_hub
        self.application_name = application_name
        self.type_name = type_name
        self.path = make_path(self.hub.base_path, type_name, application_name)
        self.cache = make_cache(self.hub.client, self.path)
        self.initialized = Event()
        self._started = False
        self._closed = False
        self.cluster_resolver = ClusterResolver(
            self.get_service_info, self.get_cluster_info)
        if semaphore is None:
            self.throttle_semaphore = Semaphore()
        else:
            self.throttle_semaphore = semaphore 
开发者ID:huskar-org,项目名称:huskar,代码行数:19,代码来源:holder.py

示例5: __init__

# 需要导入模块: from gevent import event [as 别名]
# 或者: from gevent.event import Event [as 别名]
def __init__(self, config):
        self._configure(config)

        # Since some MonitorNetwork objs are polling and some aren't....
        self.gl_methods = ['update_profit']

        # Child jobmanagers
        self.jobmanagers = {}
        self.price_data = {}
        self.profit_data = {}
        self.next_network = None
        self.current_network = None

        # Currently active jobs keyed by their unique ID
        self.jobs = {}
        self.new_job = Event()

        self.redis = redis.Redis(**self.config['redis']) 
开发者ID:simplecrypto,项目名称:powerpool,代码行数:20,代码来源:switching_jobmanager.py

示例6: __init__

# 需要导入模块: from gevent import event [as 别名]
# 或者: from gevent.event import Event [as 别名]
def __init__(self, config):
        self._configure(config)
        NodeMonitorMixin.__init__(self)

        self.new_job = Event()
        self.last_signal = 0.0
        self.last_work = {'hash': None}
        self.block_stats = dict(accepts=0,
                                rejects=0,
                                stale=0,
                                solves=0,
                                last_solve_height=None,
                                last_solve_time=None,
                                last_solve_worker=None)
        self.current_net = dict(difficulty=None, height=None, last_block=0.0)
        self.recent_blocks = deque(maxlen=15) 
开发者ID:simplecrypto,项目名称:powerpool,代码行数:18,代码来源:monitor_aux_network.py

示例7: test_eventual_coalesce

# 需要导入模块: from gevent import event [as 别名]
# 或者: from gevent.event import Event [as 别名]
def test_eventual_coalesce():
    ref = {'value': 0}
    done = Event()
    e = Eventual(None)

    def func():
        ref['value'] += 1

        # Only the first time
        if ref['value'] == 1:
            e.set_next_schedule(datetime.utcnow() - timedelta(seconds=10))
            time.sleep(1)
            done.set()

    e.function = func
    e.set_next_schedule(datetime.utcnow() + timedelta(milliseconds=500))
    done.wait()
    assert ref['value'] == 1 
开发者ID:b1naryth1ef,项目名称:rowboat,代码行数:20,代码来源:test_util_timing.py

示例8: __init__

# 需要导入模块: from gevent import event [as 别名]
# 或者: from gevent.event import Event [as 别名]
def __init__(self, listener, handle=None, spawn='default'):
        self._stop_event = Event()
        self._stop_event.set()
        self._watcher = None
        self._timer = None
        self._handle = None
        # XXX: FIXME: Subclasses rely on the presence or absence of the
        # `socket` attribute to determine whether we are open/should be opened.
        # Instead, have it be None.
        self.pool = None
        try:
            self.set_listener(listener)
            self.set_spawn(spawn)
            self.set_handle(handle)
            self.delay = self.min_delay
            self.loop = get_hub().loop
            if self.max_accept < 1:
                raise ValueError('max_accept must be positive int: %r' % (self.max_accept, ))
        except:
            self.close()
            raise 
开发者ID:priyankark,项目名称:PhonePi_SampleServer,代码行数:23,代码来源:baseserver.py

示例9: __init__

# 需要导入模块: from gevent import event [as 别名]
# 或者: from gevent.event import Event [as 别名]
def __init__(self, callback):
        self.callback = callback
        self.listeners = []
        self.message_constructors = dict()
        self.message_events = dict()
        self.message_job_events = dict()

        self.username = None
        self.jobid = 0
        self.steam2_ticket = None
        self.session_token = None
        self.server_list = dict()
        self.account_type = None

        self.connection = TCPConnection(self)
        self.connection_event = Event()
        self.logon_event = Event()

        self.register_listener(callback)
        self.steamapps = SteamApps(self)

        self.register_message(EMsg.ClientLogOnResponse, msg_base.ProtobufMessage, steammessages_clientserver_pb2.CMsgClientLogonResponse)
        self.register_message(EMsg.ClientLoggedOff, msg_base.ProtobufMessage, steammessages_clientserver_pb2.CMsgClientLoggedOff)
        self.register_message(EMsg.ClientSessionToken, msg_base.ProtobufMessage, steammessages_clientserver_pb2.CMsgClientSessionToken) 
开发者ID:adamb70,项目名称:CSGO-Market-Float-Finder,代码行数:26,代码来源:client.py

示例10: __init__

# 需要导入模块: from gevent import event [as 别名]
# 或者: from gevent.event import Event [as 别名]
def __init__(self, account_id, namespace_id, email_address, folder_id,
                 folder_name, provider_name, poll_frequency=1,
                 scope=None):

        self.account_id = account_id
        self.namespace_id = namespace_id
        self.provider_name = provider_name
        self.poll_frequency = poll_frequency
        self.scope = scope

        self.log = logger.new(account_id=account_id)

        self.shutdown = event.Event()
        self.heartbeat_status = HeartbeatStatusProxy(self.account_id,
                                                     folder_id,
                                                     folder_name,
                                                     email_address,
                                                     provider_name)
        Greenlet.__init__(self) 
开发者ID:nylas,项目名称:sync-engine,代码行数:21,代码来源:base_sync.py

示例11: create_event

# 需要导入模块: from gevent import event [as 别名]
# 或者: from gevent.event import Event [as 别名]
def create_event(use_greenlets):
    if use_greenlets:
        return GeventEvent()
    else:
        return threading.Event() 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:thread_util.py

示例12: __init__

# 需要导入模块: from gevent import event [as 别名]
# 或者: from gevent.event import Event [as 别名]
def __init__(self, rsc):
        Monitor.__init__(self, rsc, threading.Event)
        threading.Thread.__init__(self)
        self.setName("ReplicaSetMonitorThread")
        self.setDaemon(True) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:mongo_replica_set_client.py

示例13: watch

# 需要导入模块: from gevent import event [as 别名]
# 或者: from gevent.event import Event [as 别名]
def watch(self, key, timeout=None, recursive=None, sort=False):
        key = _normalize_path(key)
        segments = key.lstrip('/').split('/')
        path = ''
        parent = '/'
        watch_event = Event()
        event_paths = []

        for s in segments:
            if parent not in self._watch_event_r:
                self._watch_event_r[parent] = set()
            if parent not in self._watch_event:
                self._watch_event[parent] = set()
            if recursive:
                event_paths.append(parent)
                self._watch_event_r[parent].add(watch_event)

            path += '/' + s
            parent = path

        if path not in self._watch_event_r:
            self._watch_event_r[path] = set()
        if path not in self._watch_event:
            self._watch_event[path] = set()

        if recursive:
            event_paths.append(key)
            self._watch_event_r[key].add(watch_event)
        else:
            self._watch_event[key].add(watch_event)

        if not watch_event.wait(timeout):
            raise TimeoutError

        if recursive:
            for p in event_paths:
                self._watch_event_r[p].remove(watch_event)
        else:
            self._watch_event[key].remove(watch_event)

        return self.read(key, recursive=recursive, sort=sort) 
开发者ID:mars-project,项目名称:mars,代码行数:43,代码来源:kvstore.py

示例14: __init__

# 需要导入模块: from gevent import event [as 别名]
# 或者: from gevent.event import Event [as 别名]
def __init__(self, servers, *args, **kw):
        super(GEventServerRack, self).__init__(*args, **kw)
        self.servers = servers
        e = self._shutdown_event = Event()
        e.set() 
开发者ID:OpenMTC,项目名称:OpenMTC,代码行数:7,代码来源:ServerRack.py

示例15: _run

# 需要导入模块: from gevent import event [as 别名]
# 或者: from gevent.event import Event [as 别名]
def _run(self):
        self.m2m_app.run(self, self.m2m_ep)

        shutdown_event = GEventEvent()
        gevent.signal(SIGTERM, shutdown_event.set)
        gevent.signal(SIGINT, shutdown_event.set)
        shutdown_event.wait() 
开发者ID:OpenMTC,项目名称:OpenMTC,代码行数:9,代码来源:__init__.py


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