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
Fix win sleep bug #2758
Fix win sleep bug #2758
Conversation
Related issues: #2711.
src/textual/_win_sleep.py
Outdated
@@ -37,32 +49,62 @@ def sleep(secs: float) -> None: | |||
sleep_for = max(0, secs - 0.001) | |||
if sleep_for < 0.0005: | |||
# Less than 0.5ms and its not worth doing the sleep | |||
return | |||
return time_sleep_coro(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this isn't run in a thread context somewhere, it will block all asyncio tasks from running.
If this is ultimately calling time.sleep(0)
then it could end up sleeping for several milliseconds. sleep(0)
basically means give up your time slice and go run another thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about returning None
in this case and then checking for it in _time
?
See 0c32c05.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could just return a coroutine that does nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done e3f9dc1.
@rodrigogiraoserrao Failing tests there |
Pushed a possible fix. But what I really need is help with the regression test. That's why this is a draft. |
cb83819
to
9053fa3
Compare
9053fa3
to
d47a126
Compare
Fixes #2711