本文整理汇总了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
示例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
示例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()
示例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
示例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'])
示例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)
示例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
示例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
示例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)
示例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)
示例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()
示例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)
示例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)
示例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()
示例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()