-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loop.call_later(0) and Loop.call_later(-1) return a uvloop.loop.Handle and not an asyncio.TimerHandle #482
Comments
@fantix I think the issue here is that uvloop should not use uv_idle_callback for call_soon, Instead uvloop should schedule a timer for running with uv_timer_init set at for the loop.call_soon calls, whenever there are items added to the self._ready deque uvloop should start the "call_soon_handle", when the timer fires (note it will always fire first because it is the only timer scheduled at for loop.call_later calls scheduled in the past uvloop should maintain an internal "self._call_later_expired". whenever call_soon_handle is called after calling all of the "_ready" callbacks uvloop should clear the original self._call_later_expired heap and then call all the handles in a copy of the call_later_expired heap for call_later in the future the behavior can remain the same |
import asyncio
import uvloop
from functools import partial
async def main():
loop = asyncio.get_running_loop()
loop.call_later(-0.5, partial(print, "4", end=""))
loop.call_later(-1, partial(print, "3", end=""))
loop.call_soon(partial(print, "1", end=""))
await asyncio.sleep(0)
print("2", end="")
print("asyncio")
asyncio.run(main())
print()
uvloop.install()
print("uvloop")
asyncio.run(main())
print()
# asyncio
# 1234
# uvloop
# 4312 |
PYTHONASYNCIODEBUG
in env?: yesthe bug is here:
uvloop/uvloop/loop.pyx
Lines 1327 to 1328 in 5926386
The text was updated successfully, but these errors were encountered: