-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat: Raise exception in tests when blocking code is called in event loop #4293
base: main
Are you sure you want to change the base?
Conversation
a3487cf
to
1449e96
Compare
|
||
|
||
def init(): | ||
time.sleep = _raise_if_blocking(time.sleep) |
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.
One drawback of patching time.sleep is that debugging with breakpoints in test will raise the BlockingError
.
So this behavior should probably be configurable.
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.
Maybe a fixture? I debug a lot through tests
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.
Yes, me too.
Maybe there could be en env var RAISE_ON_BLOCKING_TIME_SLEEP
that we set by default to false
. And that we set to true
in CI ?
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.
I like that option
1449e96
to
7837c19
Compare
@@ -93,15 +94,16 @@ async def _queue_event(self, payload) -> None: | |||
async def log_package_version(self) -> None: | |||
python_version = ".".join(platform.python_version().split(".")[:2]) | |||
version_info = get_version_info() | |||
architecture = platform.architecture()[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.
Detected by the block buster 😀
No description provided.