Run_sync (v3) raises `AsyncLibraryNotFoundError` for python3.6
See original GitHub issueProblem
The AsyncLibraryNotFoundError
is getting raised for running a synchronous function in a worker thread in py3.6.
For more context, Jupyter Server #505
How to reproduce
Python version: Python 3.6.13 :: Anaconda, Inc.
Confirm AsyncLibraryNotFoundError
isn’t raised for anyio==2.2.0
.
$ pip install anyio==2.2.0
$ python test_run_sync.py
AsyncLibraryNotFoundError
shows up for anyio==3.0.1
in python3.6. I ran this in python3.7, and the error didn’t show up.
$ pip install anyio==3.0.1
$ python test_run_sync.py
Exception in callback WorkerThread.stop(<Task finishe...> result=None>)
handle: <Handle WorkerThread.stop(<Task finishe...> result=None>)>
Traceback (most recent call last):
File "/Users/mwaka/opt/anaconda3/envs/jp_test_3.6/lib/python3.6/asyncio/events.py", line 145, in _run
self._callback(*self._args)
File "/Users/mwaka/opt/anaconda3/envs/jp_test_3.6/lib/python3.6/site-packages/anyio/_backends/_asyncio.py", line 708, in stop
_threadpool_workers.get().discard(self)
File "/Users/mwaka/opt/anaconda3/envs/jp_test_3.6/lib/python3.6/site-packages/anyio/lowlevel.py", line 113, in get
return self._current_vars[self._name]
File "/Users/mwaka/opt/anaconda3/envs/jp_test_3.6/lib/python3.6/site-packages/anyio/lowlevel.py", line 97, in _current_vars
token = current_token()
File "/Users/mwaka/opt/anaconda3/envs/jp_test_3.6/lib/python3.6/site-packages/anyio/lowlevel.py", line 54, in current_token
return get_asynclib().current_token()
File "/Users/mwaka/opt/anaconda3/envs/jp_test_3.6/lib/python3.6/site-packages/anyio/_core/_eventloop.py", line 109, in get_asynclib
asynclib_name = sniffio.current_async_library()
File "/Users/mwaka/opt/anaconda3/envs/jp_test_3.6/lib/python3.6/site-packages/sniffio/_impl.py", line 82, in current_async_library
"unknown async library, or not in async context"
sniffio._impl.AsyncLibraryNotFoundError: unknown async library, or not in async context
The test_run_sync.py
script: https://gist.github.com/mwakaba2/e76b0bc341bf17c97ff58cd4c672e4d4
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Anyio version v3 breaks AsyncContentsManager for python3.6
Description AsyncFileContentsManager tests are timing out in a python 3.6 environment due to a AsyncLibraryNotFoundError error.
Read more >Is there a way to define a function that can be used as a nomal ...
I'm not proposing a solution. The “not” is because I'm really doubtful about it. Instead of writing: async def f(): [some code] await...
Read more >"This package should not be accessible on Python 3" when ...
Your environment contains PYTHONPATH=/usr/local/lib/python2.7/site-packages. This doesn't work with Python 3 for obvious reasons. To remove it:
Read more >Using pip3 to install Python3 modules
To use pip3, first install a custom version of Python 3. pip3 is then installed with it. Installing a custom version of Python...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, the test fails without the fix.
@agronholm Thanks so much for the quick fix!
In your PR, I see a test that checks for any exceptions in
run_sync
. Were you able to reproduce the exception before the fix?