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

Bug:App with RabbitBroker fails in v0.5.25 #1837

Open
hoelzl opened this issue Oct 7, 2024 · 2 comments
Open

Bug:App with RabbitBroker fails in v0.5.25 #1837

hoelzl opened this issue Oct 7, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@hoelzl
Copy link

hoelzl commented Oct 7, 2024

Instantiating a FastStream instance with a RabbitBroker fails in version 0.5.25:

How to reproduce

from faststream import FastStream
from faststream.rabbit import RabbitBroker

broker = RabbitBroker("amqp://guest:guest@localhost/")
app = FastStream(broker)

Expected behavior
app is a valid object

Observed behavior
I get the following error:

In [1]: from faststream import FastStream
   ...: from faststream.rabbit import RabbitBroker
   ...:
   ...: broker = RabbitBroker("amqp://guest:guest@localhost/")
   ...: app = FastStream(broker)
---------------------------------------------------------------------------
AsyncLibraryNotFoundError                 Traceback (most recent call last)
Cell In[1], line 5
      2 from faststream.rabbit import RabbitBroker
      4 broker = RabbitBroker("amqp://guest:guest@localhost/")
----> 5 app = FastStream(broker)

File /opt/conda/lib/python3.11/site-packages/faststream/_internal/application.py:74, in Application.__init__(self, broker, logger, lifespan, title, version, description, terms_of_service, license, contact, tags, external_docs, identifier, on_startup, after_startup, on_shutdown, after_shutdown)
     50 def __init__(
     51     self,
     52     broker: Optional["BrokerUsecase[Any, Any]"] = None,
   (...)
     70     after_shutdown: Sequence[Callable[P_HookParams, T_HookReturn]] = (),
     71 ) -> None:
     72     context.set_global("app", self)
---> 74     self._should_exit = anyio.Event()
     75     self.broker = broker
     76     self.logger = logger

File /opt/conda/lib/python3.11/site-packages/anyio/_core/_synchronization.py:79, in Event.__new__(cls)
     78 def __new__(cls) -> Event:
---> 79     return get_asynclib().Event()

File /opt/conda/lib/python3.11/site-packages/anyio/_core/_eventloop.py:147, in get_asynclib(asynclib_name)
    145 def get_asynclib(asynclib_name: str | None = None) -> Any:
    146     if asynclib_name is None:
--> 147         asynclib_name = sniffio.current_async_library()
    149     modulename = "anyio._backends._" + asynclib_name
    150     try:

File /opt/conda/lib/python3.11/site-packages/sniffio/_impl.py:93, in current_async_library()
     90     if curio_running():
     91         return 'curio'
---> 93 raise AsyncLibraryNotFoundError(
     94     "unknown async library, or not in async context"
     95 )

AsyncLibraryNotFoundError: unknown async library, or not in async context

Additional context
This is probably due to #1683.

@hoelzl hoelzl added the bug Something isn't working label Oct 7, 2024
@Lancetnik
Copy link
Member

It is interesting, could you please provide information about faststream, anyio versions and your platform?

Just an output of faststream --version command and anyio

@Lancetnik
Copy link
Member

Are you really using curio? With default setup your example works as expected

github-merge-queue bot pushed a commit that referenced this issue Oct 8, 2024
* fix (#1837): explicit asyncio.Event usage

* fix: correct CLI object import in factory case

* chore: bump version

* chore: revert anyio

* fix: respect extra reload extensions CLI option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants