-
Notifications
You must be signed in to change notification settings - Fork 310
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
Anyio version v3 breaks AsyncContentsManager for python3.6 #505
Comments
AnyIO relies on sniffio to detect the current async library. It cannot function without this detection. The only difference between py3.6 and 3.7 that would matter here is the support for context variables. This looks like it happens in the callback where the asyncio thread pool is being shut down. I will try to figure this out. |
@agronholm I think I found the issue. For python 3.6, the contextvar if (3, 7) <= sys.version_info:
# asyncio has contextvars support, and we're in a task, so
# we can safely cache the sniffed value
current_async_library_cvar.set("asyncio") After updating the "if condition" to the following, the tests are passing now. if sys.version_info <= (3, 7): However, I noticed that this "if condition" was removed recently here. I tested against the latest sniffio commit, and I'm still getting the same error message. One strange thing I noticed was that the |
Good to know. So it works if you downgrade sniffio? |
Lookin at the commit you pointed to, it's just an optimization. It would seem strange if something was broken by it. Can you create a minimal reproducing script for this? |
Downgrading won't help because the if condition isn't checking the version_info correctly. It's checking whether (3, 7) is less than py3.6, but that'll return |
It just means it won't cache the result. It's a performance optimization. |
Sorry I misunderstood. I thought setting the context var was needed for versions less than 3.7, but it's for 3.7 and up.
Yeah, I can look into that. Also, do you know why the optimization was removed recently? |
We realized that sniffio should use a thread-local instead of a context-local variable, to better handle some complicated cases involving where different async libraries are calling into each other. The optimization only works for context-locals, so we had to remove it when we moved away from using context-locals. |
ah I see, thanks for the clarification! |
@agronholm I was able to create a minimal reproducing script. I included that in a new anyio issue: agronholm/anyio#286 I'd appreciate if you can take a look. |
Hi @agronholm I noticed the fix has been merged. Do you know when anyio will release the new fix? |
I have a couple more PRs to go through and then I'll make the v3.1.0 release. ETA 1-3 days. |
sounds good! thanks for the update! |
Still working out PR agronholm/anyio#289. After that's dealt with I will make a release. |
v3.1.0 is out now. |
thank you @agronholm ! I'll update the anyio version in jupyter server. |
Description
AsyncFileContentsManager tests are timing out in a python 3.6 environment due to a
AsyncLibraryNotFoundError
error.Reproduce
Expected behavior
The tests should pass in ~10 seconds.
Context
Python 3.6.13 |Anaconda, Inc.| (default, Feb 23 2021, 12:58:59)
The text was updated successfully, but these errors were encountered: