Skip to content
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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cbornet
Copy link
Collaborator

@cbornet cbornet commented Oct 26, 2024

No description provided.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Oct 26, 2024
@cbornet cbornet marked this pull request as draft October 26, 2024 22:52


def init():
time.sleep = _raise_if_blocking(time.sleep)
Copy link
Collaborator Author

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.

Copy link
Contributor

@ogabrielluiz ogabrielluiz Oct 27, 2024

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

Copy link
Collaborator Author

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 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that option

@@ -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]
Copy link
Collaborator Author

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 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants