prompt-toolkit / prompt-toolkit/python-prompt-toolkit
RuntimeError: Event loop is closed
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
It seems from the traceback that a Runtime error is triggered at:
File "/usr/local/lib/python3.8/dist-packages/prompt_toolkit/application/application.py", line 816, in run
return loop.run_until_complete(
It seems to be triggered when multiple libs interact. It is difficult to pin-point which lib is most responsible, but the tracestack shows prompt-toolkit as the first non-standard one. Sorry.
Can you help?
I run Python 3.8.6, prompt_toolkit.version = '3.0.8'
======SMALL PYTHON SCRIPT TO TEST IT====================
#!/usr/bin/python3
import subprocess
from questionary import prompt, Separator
from datalad import api as datalad
question = [{'type': 'list', 'name': 'choice', 'message': 'Menu', 'choices': ['Red pill','Blue pill']}]
print("You have to take four pills")
for i in range(4):
answer = prompt(question)
name = answer['choice'].replace(' ','_')+str(i)
print("Create path: "+name)
### does not work
ds = datalad.create(name, cfg_proc='text2git')
### works perfectly
# cmd = ['datalad','create','-c','text2git',name]
# output = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print("Log: dataset created. Success")
=========MY OUTPUT ==========================================
You have to take four pills
? Menu Blue pill
Create path: Blue_pill0
[INFO ] Creating a new annex repo at /home/sbrinckm/tttttt/Blue_pill0
[INFO ] Running procedure cfg_text2git
[INFO ] == Command start (output follows) =====
[INFO ] == Command exit (modification check follows) =====
Log: dataset created. Success
Traceback (most recent call last):
File "short.py", line 9, in <module>
answer = prompt(question)
File "/usr/local/lib/python3.8/dist-packages/questionary/prompt.py", line 97, in prompt
answer = question.unsafe_ask(patch_stdout)
File "/usr/local/lib/python3.8/dist-packages/questionary/question.py", line 59, in unsafe_ask
return self.application.run()
File "/usr/local/lib/python3.8/dist-packages/prompt_toolkit/application/application.py", line 816, in run
return loop.run_until_complete(
File "/usr/lib/python3.8/asyncio/base_events.py", line 591, in run_until_complete
self._check_closed()
File "/usr/lib/python3.8/asyncio/base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
sys:1: RuntimeWarning: coroutine 'Application.run_async' was never awaited
================================================================
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied script with Python 3.8.6 and prompt_toolkit 3.0.8, then inspect prompt_toolkit/application/application.py around application.run at line 816. Compare the repeated prompt call after datalad.create with the subprocess variant. Done means the repeated prompts no longer fail with a closed event loop or emit the unawaited coroutine warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100