-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature request: Warn on blocking call allowed #34
Comments
Hi Tomas,
One thing to be aware of is that some wrapped functions are really called a lot (eg:
Yes, I've been thinking about it too. WDYT ? Would that fit your need ? |
This idea seems to offer a lot of flexibility, more than I would need, but it would definitely help with the warnings I want to raise.
The current branch I'm working with has a test file that it's pretty much allowing every Happy to work on a PR for these two features! |
Note that you can already do something like this: https://github.com/langchain-ai/langchain/blob/6c1e21d1282a824fea52225f7b87e24a4edc95d7/libs/core/tests/unit_tests/conftest.py#L31C9-L34C14 |
I work with dependencies that implement asynchronous APIs but for one reason or another cannot remove all of their blocking calls1. Naturally, following blockbuster's README, we have a lot of these blocking calls allowed by calling
can_block_in
in our test suite.However, I would like to be informed when:
can_block_in
rule was set.can_block_in
rule.The first point could be useful to remove
can_block_in
calls as my dependencies slowly remove any remaining blocking calls.The second point is more personal: I have a
pytest.fixture
that initializes ablockbuster_ctx
and callscan_block_in
a bunch of times to allow blocking calls from dependencies. The fixture is then passed around to all tests. I fear that me or my team will eventually forget which blocking calls we were allowing, and that this will cause us to underestimate how much we are blocking the event loop. Thus, I would like to be reminded of what I am allowing.This could be achieved by raising a warning somewhere in the wrapper code, although I haven't looked closely enough. Happy to dig more and put up a PR if this is considered relevant!
Sidenote: Maybe
can_block_in
could allow all blocking calls from a particular path/module? This way only one warning would be raised.Finally, thanks for your work in blockbuster! I had been looking for something like this for a while after many a production issue due to an unexpected blocking call going on for too long in code that seemed non-blocking.
Footnotes
As an example, here is some discussion going on in
aiobotocore
due to blocking filesystem calls. ↩The text was updated successfully, but these errors were encountered: