Properly rerun application in InteractiveSession if needed
This commit is contained in:
@@ -184,7 +184,9 @@ class InteractiveSession(dict[str, _SCT]):
|
|||||||
dict.__init__(self, **content)
|
dict.__init__(self, **content)
|
||||||
|
|
||||||
def __enter__(self, *args, **kwargs) -> 'InteractiveSession[_SCT]':
|
def __enter__(self, *args, **kwargs) -> 'InteractiveSession[_SCT]':
|
||||||
|
is_already_running = interactive_application is not None
|
||||||
self.application = request_application(*self.values())
|
self.application = request_application(*self.values())
|
||||||
|
if not is_already_running:
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
self.thread = Thread(target=lambda: self.application.run())
|
self.thread = Thread(target=lambda: self.application.run())
|
||||||
self.thread.start()
|
self.thread.start()
|
||||||
@@ -193,6 +195,7 @@ class InteractiveSession(dict[str, _SCT]):
|
|||||||
def __exit__(self, *args, **kwargs) -> None:
|
def __exit__(self, *args, **kwargs) -> None:
|
||||||
clear_application(*self.values())
|
clear_application(*self.values())
|
||||||
if hasattr(self, "thread"):
|
if hasattr(self, "thread"):
|
||||||
|
assert interactive_application is None
|
||||||
self.thread.join()
|
self.thread.join()
|
||||||
del self.thread
|
del self.thread
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user