當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。