Skip to content

call_later should always return TimerHandle - #704

Open
jensbjorgensen wants to merge 3 commits into
MagicStack:masterfrom
jensbjorgensen:master
Open

jensbjorgensen wants to merge 3 commits into
MagicStack:masterfrom
jensbjorgensen:master

Conversation

@jensbjorgensen

Copy link
Copy Markdown
Contributor

Python's builtin asyncio Loop always returns a TimerHandle from call_later/call_at, however current uvloop will instead fall back to call_soon if delay==0. It seems desirable that uvloop be api-compatible. I'm sure there's a little performance improvement from call_soon if you can use it, but end-users call always use call_soon anyway if they know the delay is zero.

Demonstration:

import asyncio, uvloop
asyncio.new_event_loop().call_later(0, lambda : None).when()
uvloop.new_event_loop().call_later(0, lambda : None).when()

@jensbjorgensen

Copy link
Copy Markdown
Contributor Author

oops sorry about the mis-formatting in the first commit, that's fixed now. I see macos tests failing, but this doesn't seem to be due to me.

@Vizonex Vizonex left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting idea, I can see where your coming from with just using TimerHandle for uvloop, I guess my only gripe might be memory related where using the subclass could eat more memory but when it comes to being accurate with asyncio, this is perfect. I'll approve this PR because the implementation to asyncio is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants