lib.ExecApp: Add class #76
1 changed files with 1 additions and 2 deletions
lib.App: Restore caller's event loop in run()
run() remembers the thread's current event loop before creating a new one only when the app does not own a loop yet. The finally block, however, always restores the remembered loop or unsets the loop when there was none. So when a caller passes its own event loop to the App constructor and has set it as the thread's current loop, run() unsets the thread's loop on the way out, although it never changed it. Remember the thread's current event loop unconditionally and restore it in the finally block; for a caller-provided loop that is a no-op. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2 Signed-off-by: Jan Lindemann <jan@janware.com>
commit
8f52639d14
|
|
@ -513,9 +513,8 @@ class App: # export
|
|||
return self.__parser
|
||||
|
||||
def run(self, argv: list[str] | None = None) -> None:
|
||||
previous_eloop: asyncio.AbstractEventLoop | None = None
|
||||
if self.__eloop is None:
|
||||
previous_eloop = _get_current_event_loop()
|
||||
if self.__eloop is None:
|
||||
eloop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(eloop)
|
||||
self.__eloop = eloop
|
||||
|
|
|
|||
Loading…
Reference in a new issue