[issue45194] asyncio scheduler jitter

2021-09-14 Thread QuadCorei8085


New submission from QuadCorei8085 :

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 
<https://bugs.python.org/issue45194>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45194] asyncio scheduler jitter

2021-09-14 Thread QuadCorei8085


QuadCorei8085  added the comment:

correction:
a) of course i meant loop.create_task(test_task())

b) when using threading the sleep returns every 1000ms when going lower 10-15ms 
is also spot on. (I wanted to use threading in my app but one library - 
websocket - is asyncio based thus i'm stuck with asyncio)

--

___
Python tracker 
<https://bugs.python.org/issue45194>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com