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

falcon.async_to_sync() does not work inside an async loop #2321

Open
vytas7 opened this issue Sep 5, 2024 · 2 comments
Open

falcon.async_to_sync() does not work inside an async loop #2321

vytas7 opened this issue Sep 5, 2024 · 2 comments
Labels
bug needs contributor Comment on this issue if you'd like to volunteer to work on this. Thanks!
Milestone

Comments

@vytas7
Copy link
Member

vytas7 commented Sep 5, 2024

The easiest way to reproduce is running the Python REPL in async mode:

python -m asyncio
>>> import asyncio
>>> import falcon
>>> async def noop(): ...
... 
>>> falcon.async_to_sync(noop)
Traceback (most recent call last):
  <...>
RuntimeError: Runner.run() cannot be called from a running event loop
@vytas7 vytas7 added the bug label Sep 5, 2024
@vytas7 vytas7 added this to the Version 4.x milestone Sep 5, 2024
@vytas7
Copy link
Member Author

vytas7 commented Sep 5, 2024

Note that it is not a very high priority issue to fix since the primary use case of falcon.async_to_sync() is running it from synchronous code outside of any loop.

But if there is an elegant solution, it would be nice to fix it. I know SQLAlchemy uses Greenlet to achieve this.

@vytas7 vytas7 added the needs contributor Comment on this issue if you'd like to volunteer to work on this. Thanks! label Sep 5, 2024
@CaselIT
Copy link
Member

CaselIT commented Sep 5, 2024

Personally I think there should just be a mention of it in the function docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs contributor Comment on this issue if you'd like to volunteer to work on this. Thanks!
Projects
None yet
Development

No branches or pull requests

2 participants