mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-15 10:22:20 +08:00
We can't use async as a variable name in python 3.7 because it's now a keyword. Support gevent's new 'async_' name.
This commit is contained in:
parent
569f7403a9
commit
a2630a68a6
@ -1524,15 +1524,20 @@ def init(event_model=None):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
class ThreadEvent(object):
|
class ThreadEvent(object):
|
||||||
|
has_async_ = hasattr(gevent.get_hub().loop, 'async_')
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.async = gevent.get_hub().loop.async()
|
if ThreadEvent.has_async_:
|
||||||
self.async.start(nullf)
|
self.gevent_async = gevent.get_hub().loop.async_()
|
||||||
|
else:
|
||||||
|
self.gevent_async = getattr(gevent.get_hub().loop, 'async')()
|
||||||
|
|
||||||
|
self.gevent_async.start(nullf)
|
||||||
|
|
||||||
def set(self):
|
def set(self):
|
||||||
self.async.send()
|
self.gevent_async.send()
|
||||||
|
|
||||||
def wait(self):
|
def wait(self):
|
||||||
gevent.get_hub().wait(self.async)
|
gevent.get_hub().wait(self.gevent_async)
|
||||||
else:
|
else:
|
||||||
# gevent 0.x doesn't have async, so use a pipe. This doesn't work on Windows.
|
# gevent 0.x doesn't have async, so use a pipe. This doesn't work on Windows.
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user