structio.thread.run_coro now makes sure the event loop is running before submitting tasks

This commit is contained in:
Mattia Giambirtone 2023-10-26 12:00:45 +02:00
parent d5b9564d7a
commit 2aecb7f440
Signed by: nocturn9x
GPG Key ID: 8270F9F467971E59
1 changed files with 1 additions and 1 deletions

View File

@ -346,7 +346,7 @@ def run_coro(
pass
else:
raise StructIOException("cannot be called from async context")
if not is_async_thread():
if not is_async_thread() or _storage.parent_loop.done():
raise StructIOException("run_coro requires a running loop in another thread!")
# Wake up the event loop if it's blocked in a call to select() or similar I/O routine
_storage.coro_runner.wakeup()