From 2aecb7f4406f211c42189ea0ca8f7e176febe5ba Mon Sep 17 00:00:00 2001 From: nocturn9x Date: Thu, 26 Oct 2023 12:00:45 +0200 Subject: [PATCH] structio.thread.run_coro now makes sure the event loop is running before submitting tasks --- structio/thread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/structio/thread.py b/structio/thread.py index 2fb95b7..3a774fd 100644 --- a/structio/thread.py +++ b/structio/thread.py @@ -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()