Skip to content

Commit

Permalink
application: fix DeprecationWarning (#1798)
Browse files Browse the repository at this point in the history
  • Loading branch information
doronz88 authored and jonathanslenders committed Nov 3, 2023
1 parent adc057b commit 27cb5c0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/prompt_toolkit/application/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,13 @@ def run_in_thread() -> None:
# See whether a loop was installed already. If so, use that. That's
# required for the input hooks to work, they are installed using
# `set_event_loop`.
loop = asyncio.get_event_loop()
if sys.version_info < (3, 10):
loop = asyncio.get_event_loop()
else:
try:
loop = asyncio.get_running_loop()
except RuntimeError:
loop = asyncio.new_event_loop()
except RuntimeError:
# No loop installed. Run like usual.
return asyncio.run(coro)
Expand Down

0 comments on commit 27cb5c0

Please sign in to comment.