python-trio / trio

Trio – a friendly Python library for async concurrency and I/O
https://trio.readthedocs.io
Other
5.98k stars 325 forks source link

AttributeError: module 'trio' has no attribute 'MultiError' #2949

Closed FilipeMarch closed 4 months ago

FilipeMarch commented 4 months ago

Bug Description

main.py

import asks, trio

async def get_google():
    response = await asks.get("https://google.com")
    print(response)

trio.run(get_google)

Executing python main.py results in the following error:

Traceback (most recent call last):
File ".venv/lib/python3.11/site-packages/anyio/_core/_eventloop.py", line 151, in get_asynclib
return sys.modules[modulename]
~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'anyio._backends._trio'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "main.py", line 9, in <module>
trio.run(get_google)
File ".venv/lib/python3.11/site-packages/trio/_core/_run.py", line 2275, in run
raise runner.main_task_outcome.error
File "main.py", line 5, in get_google
response = await asks.get("https://google.com")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.11/site-packages/asks/base_funcs.py", line 30, in request
r = await s.request(method, url=uri, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.11/site-packages/asks/sessions.py", line 198, in request
async with self.sema:
File ".venv/lib/python3.11/site-packages/anyio/_core/_synchronization.py", line 300, in __aenter__
await self.acquire()
File ".venv/lib/python3.11/site-packages/anyio/_core/_synchronization.py", line 313, in acquire
await checkpoint_if_cancelled()
File ".venv/lib/python3.11/site-packages/anyio/lowlevel.py", line 45, in checkpoint_if_cancelled
await get_asynclib().checkpoint_if_cancelled()
^^^^^^^^^^^^^^
File ".venv/lib/python3.11/site-packages/anyio/_core/_eventloop.py", line 153, in get_asynclib
return import_module(modulename)
^^^^^^^^^^^^^^^^^^^^^^^^^
File ".pyenv/versions/3.11.6/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File ".venv/lib/python3.11/site-packages/anyio/_backends/_trio.py", line 162, in <module>
class ExceptionGroup(BaseExceptionGroup, trio.MultiError):
^^^^^^^^^^^^^^^
File ".venv/lib/python3.11/site-packages/trio/_deprecate.py", line 153, in __getattr__
raise AttributeError(msg.format(self.__name__, name))
AttributeError: module 'trio' has no attribute 'MultiError'

Reproduction

python main.py

Environment

oremanj commented 4 months ago

asks requires anyio < 4.0, but those versions of anyio only work with trio < 0.22.0. So your choices are:

FilipeMarch commented 4 months ago

Thanks! Maybe the time to abandon asks has come. It's sad it has been abandoned. It was so simple.

I will move into httpx then. 😕

jakkdl commented 4 months ago

(This isn't an issue for us at all, so don't think it should be labeled "good first issue". Asks also seem to have no activity since april 2022 so I don't think we should bother with an issue tracking their support or anything either.)

CoolCat467 commented 4 months ago

I thought it would be a good place to point people that we have removed MultiError, but that makes sense.

jakkdl commented 4 months ago

I think the "good first issue" label is generally meant to imply "if you're new and want to contribute to this repository, this is a conceptually easy issue that we recommend you start trying to write a PR for", rather than something for people trying to debug issues.

Though we could plausibly have a different label for issues like this.

CoolCat467 commented 4 months ago

Github has a banner I've been sure not to dismiss, saying

Now, GitHub will help potential first-time contributors discover issues labeled with good first issue

Ah, actually reading that more closely, the "first-time contributors" part of that is talking about people making pull requests, not finding issues, sorry, I somehow had thought it meant people who are creating issues for the first time and helping people not make duplicate issues. That makes sense.

TeamSpen210 commented 4 months ago

For that, there's the ability to pin up to 3 issues.