X Tutup
The Wayback Machine - https://web.archive.org/web/20200906150157/https://github.com/MagicStack/uvloop/issues/359
Skip to content
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

Uvloop internal clock is not microsecond accurate #359

Open
agronholm opened this issue Aug 27, 2020 · 5 comments
Open

Uvloop internal clock is not microsecond accurate #359

agronholm opened this issue Aug 27, 2020 · 5 comments

Comments

@agronholm
Copy link

@agronholm agronholm commented Aug 27, 2020

  • uvloop version: 0.14, master
  • Python version: 3.6
  • Platform: Linux
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: yes
  • Does uvloop behave differently from vanilla asyncio? How?: loop.time() reports time with the accuracy of milliseconds on uvloop, microseconds (or greater) on the stdlib event loop.

Today I debugged some failing tests in the httpcore project and it turns out they were relying on time passing between two subsequent operations. The code was running so fast, however, that the returned clock value on uvloop was the same as it was before, due to the lesser accuracy. This should hopefully be easy to fix.

@agronholm
Copy link
Author

@agronholm agronholm commented Aug 27, 2020

Easy repro:

from asyncio.events import get_event_loop

import uvloop

loop = get_event_loop()
print('stdlib:', loop.time())
loop.close()

uvloop.install()
loop = get_event_loop()
print('uvloop:', loop.time())
loop.close()
@jlaine
Copy link
Contributor

@jlaine jlaine commented Aug 28, 2020

That's correct, libuv only has a millisecond accuracy for its timers.

@agronholm
Copy link
Author

@agronholm agronholm commented Aug 28, 2020

Oh dear, so it's not fixable I guess?

@1st1
Copy link
Member

@1st1 1st1 commented Aug 28, 2020

Fixable by submitting a PR to libuv to allow higher resolution timers on platforms that support that. That's very doable (maybe you can work on a PR?) just might take a bit longer.

@elprans
Copy link
Member

@elprans elprans commented Aug 28, 2020

FWIW, here's an old libuv PR that is related: libuv/libuv#1191

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.
X Tutup