-
Notifications
You must be signed in to change notification settings - Fork 269
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
Add support for time.monotonic() #199
Conversation
@spulec What do you think about this PR? I have added ability to ignore |
Hi @spulec, what do you think about this PR? Is it good to be merged and released? |
It seems the tests are failing in a recursive loop. Any idea why? |
@spulec I looked into this but with no success. When I run it using makefile it fails, but when I run nosetest directly from command line it ends with two errors:
It is strange that problem occurs directly in nose before testing actually starts AFAIK:
Do you have some idea why is this happening? |
I'm not sure and unfortunately don't have time to look into it right now. Feel free to rebase and dig into the tests and we can take another look. |
This was added in #369. This PR can be closed. |
Thanks @jmehnle for the heads up |
Hello, for our testing purposes we needed
freezegun
to work also withtime.monotonic()
https://docs.python.org/3/library/time.html#time.monotonic . Specifically we needasyncio
'scall_later
function to work properly with frozen time. Our use case is as follows:So we need to have time frozen in
process
. But when inprocess
is someasyncio.call_later
it is called according to real time (time.monotonic()
). To overcome this I have written this PR, that also patchestime.monotonic()
.This works good for our purpose but there is a hidden catch: when you use
await asyncio.sleep(delta)
inprocess()
it will hang indefinitely: it makes sensetime.monotonic
is stopped so it does not know how long it should wait. This might be surprising so I'm pointing this out if we want to have this behavior infreezegun
by default or it should be an option tofreeze_time
.I need to sleep for a moment in that loop so scheduled coroutines have chance to process so I'm using this little hack:
That patches
asyncio.sleep
so it will perform but also will movefrozen_datetime
by time to sleep.What do you think about this PR?