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
RunTime Error 'Application.run_async' was never awaited #80
Comments
Hmm maybe a similar problem to prompt-toolkit/python-prompt-toolkit#1033? |
I use Ubuntu 20.04 and python 3.8. |
The crux of the issue is the same. Library A (datalad) closes the default event loop. Library B (prompt-toolkit) attempts to use the default event loop after it was closed by library A. Libraries have no business using or closing the default event loop. As a stopgap you can run |
prompt-toolkit attempts to account for this in https://github.com/prompt-toolkit/python-prompt-toolkit/blob/dd3e552c00ee44247144a7aa9cd0392a7206570f/prompt_toolkit/application/application.py#L806-L814 but calling |
I played with different versions: prompt-toolkit 2.0.10 works perfectly. I'm not sure how to handle it for my own software: make a requirement that excludes the latest prompt-toolkit, or choose the stopgap mentioned before or use system-calls/parse-output which also close the event loops correctly. |
I'm not sure it's the same issue, but at least it seems related. Pasting this in import asyncio
import questionary
async def main() -> None:
questionary.select(
"What do you want to do?",
choices=[
"Order a pizza",
"Make a reservation",
"Ask for opening hours",
],
).ask()
asyncio.run(main()) and running
|
That's because import asyncio
import questionary
async def main() -> None:
await questionary.select(
"What do you want to do?",
choices=[
"Order a pizza",
"Make a reservation",
"Ask for opening hours",
],
).ask_async()
asyncio.run(main()) |
Thanks for your quick response. Unfortunately in my use case it doesn't make sense using the async API, because all questionary calls need to be synchronous. But now it's clear this is a different issue: I'm going to open it as such. |
The stopgap "asyncio.set_event_loop(asyncio.new_event_loop()) before every prompt" works perfectly for me. |
Hallo Questionary,
I have been using questionary for a while now, but when I started linking an additional lib, a runtime warning/error gets triggered. (Although it is a warning it leads to immediate failure)
In the traceback there is mention of the ask_unsafe function. I wonder, can one from the python.api switch between the multiple ask functions that are available in question.py?
A short test script:
The trace is
The text was updated successfully, but these errors were encountered: