[New-bugs-announce] [issue45194] asyncio scheduler jitter

QuadCorei8085 report at bugs.python.org
Tue Sep 14 06:35:13 EDT 2021


New submission from QuadCorei8085 <gulyast.reg at gmail.com>:

I'm trying to do something periodically and this would be on the millisec level precision.
However for some reason I could not achieve precise timing in a task.
Below example shows that a simple sleep randomly awakes with a jitter between 0.1-20.0ms I haven't hystogrammed the distribution but it seems to be mostly 19-20ms.

Any way to achieve better timings with asyncio?

async def test_task():
    while True:
        ts_now = time.time();
        await asyncio.sleep(1.000);
        print("{}".format((time.time()-ts_now)*1000.0));

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.create_task(thread_main())
    loop.run_forever()

----------
components: asyncio
messages: 401769
nosy: QuadCorei8085, asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: asyncio scheduler jitter
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45194>
_______________________________________


More information about the New-bugs-announce mailing list