lib.App: Implement __aenter__() and __aexit__()
__aenter__() and __aexit__() are empty stubs. Using the application as an async context manager therefore binds None in the as clause, and releases nothing on exit: an AsyncRunner created through call_async() keeps running in its thread, and since that thread is not a daemon, the process does not exit after the block. Return self from __aenter__(), and call close() from __aexit__(), so that the context manager binds the application and releases all resources on exit, whether the block exits normally or with an exception. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2 Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
8c47726a8d
commit
679e66898e
1 changed files with 3 additions and 3 deletions
|
|
@ -222,8 +222,8 @@ class App: # export
|
|||
self.__eloop.close()
|
||||
self.__eloop = None
|
||||
|
||||
async def __aenter__(self) -> None:
|
||||
pass
|
||||
async def __aenter__(self) -> App:
|
||||
return self
|
||||
|
||||
async def __aexit__(
|
||||
self,
|
||||
|
|
@ -231,7 +231,7 @@ class App: # export
|
|||
exc: BaseException | None,
|
||||
tb: types.TracebackType | None,
|
||||
) -> None:
|
||||
pass
|
||||
self.close()
|
||||
|
||||
async def __run(self, argv: list[str] | None = None) -> None:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue