Skip to content

Commit 27cb5c0

Browse files
doronz88jonathanslenders
authored andcommitted
application: fix DeprecationWarning (prompt-toolkit#1798)
1 parent adc057b commit 27cb5c0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/prompt_toolkit/application/application.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,13 @@ def run_in_thread() -> None:
958958
# See whether a loop was installed already. If so, use that. That's
959959
# required for the input hooks to work, they are installed using
960960
# `set_event_loop`.
961-
loop = asyncio.get_event_loop()
961+
if sys.version_info < (3, 10):
962+
loop = asyncio.get_event_loop()
963+
else:
964+
try:
965+
loop = asyncio.get_running_loop()
966+
except RuntimeError:
967+
loop = asyncio.new_event_loop()
962968
except RuntimeError:
963969
# No loop installed. Run like usual.
964970
return asyncio.run(coro)

0 commit comments

Comments
 (0)