-
Notifications
You must be signed in to change notification settings - Fork 12
Replacing Event Loop
Fantix King edited this page Apr 28, 2014
·
3 revisions
Replace with loop.call_soon(callback, *args)
.
In gevent run_callback
returns a callback
object, while in asyncio call_soon
returns a Handle
object:
- Replace
callback.stop()
withHandle.cancel()
- Lots of gevent code judges
if not my_callback:
, butHandle
doesn't support it. As a workaround, you can reset the reference toNone
at the beginning of the callback.
In gevent code this is usually followed by a my_timer.start(callback, *args, update=True)
. Replace all the two with loop.call_later(delay, callback, *args)
.
Similarly loop.timer
returns a watcher
object, while loop.call_later
returns a Handle
object:
- Replace
my_timer.stop()
withHandle.cancel()
Replace with hub.io(fd, flag)
which returns a similar IOWatcher
object.