This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author QuadCorei8085
Recipients QuadCorei8085, asvetlov, yselivanov
Date 2021-09-14.10:35:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1631615713.39.0.358857928244.issue45194@roundup.psfhosted.org>
In-reply-to
Content
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()
History
Date User Action Args
2021-09-14 10:35:13QuadCorei8085setrecipients: + QuadCorei8085, asvetlov, yselivanov
2021-09-14 10:35:13QuadCorei8085setmessageid: <1631615713.39.0.358857928244.issue45194@roundup.psfhosted.org>
2021-09-14 10:35:13QuadCorei8085linkissue45194 messages
2021-09-14 10:35:13QuadCorei8085create