Testing asyncio code made harder due to freezing time.monotonic()
See original GitHub issueHi,
Version 1.1.0 makes it harder to test asyncio-based code relying on asyncio.sleep()
, asyncio.wait_for()
, … where what we only want to test is datetime
related. In such cases, without any auto or manual ticking all time based awaits simply freeze because :
The event loop has its own internal clock for computing timeouts. Which clock is used depends on the (platform-specific) event loop implementation; ideally it is a monotonic clock. This will generally be a different clock than time.time().
(See https://docs.python.org/3.6/library/asyncio-eventloop.html#asyncio-delayed-calls).
Would it be possible to make time.monotonic() freezing optional?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Help with asyncio program freezing during requests - Async-SIG
I'm trying to write a program to grab multiple files over http. I'm writing it using asyncio (with httpx as the HTTP library)...
Read more >Advanced asyncio testing - Stefan Scherfke
While I was working on that articel, Tin Tvrtkovic created the plug-in pytest-asyncio. In short, it lets you do this: import asyncio import...
Read more >Cooperative Multitasking in CircuitPython with asyncio
We looked at how MicroPython supports hardware interrupts and decided that the restrictions that are imposed make it harder to use and more ......
Read more >Testing asyncio code – roguelynn - Lynn Root
We want to update the testing event loop so we can override the close() behavior, which gets called in our main function.
Read more >Unit Testing Python Asyncio Code | cloudfit-public-docs
Notice that the type returned from the call to my_mock() is a coroutine, which must be awaited to produce a result, as in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That indeed did the trick for me:
Thank you very much!
That good but I don’t think this means we should close the ticket? The question is if freezegun needs to have this in the ignore list or not. I don’t think it’s obvious.
Could you maybe show a minimal program that shows this issue? I think this would help me understand if freezegun needs to be changed.