commit fe14b7164a10868c7bec12a7d25810bbbc6813b9 Author: Illia Volochii illia.volochii@gmail.com Date: Thu Apr 30 19:25:38 2020 +0300
Stop joining the thread for the asynchronous controller while closing
If it is joined, it will not be possible to reconnect. --- stem/control.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/stem/control.py b/stem/control.py index b2d2d9d7..a87e88ca 100644 --- a/stem/control.py +++ b/stem/control.py @@ -3987,8 +3987,6 @@ class Controller(_ControllerClassMethodMixin, _BaseControllerSocketMixin):
def close(self) -> None: self._execute_async_method('close') - if self._async_controller_thread.is_alive(): - self._async_controller_thread.join()
def get_latest_heartbeat(self) -> float: return self._async_controller.get_latest_heartbeat() @@ -4170,6 +4168,10 @@ class Controller(_ControllerClassMethodMixin, _BaseControllerSocketMixin): def drop_guards(self) -> None: self._execute_async_method('drop_guards')
+ def __del__(self) -> None: + if self._asyncio_loop.is_running(): + self._asyncio_loop.call_soon_threadsafe(self._asyncio_loop.stop) + def __enter__(self) -> 'stem.control.Controller': return self
tor-commits@lists.torproject.org