[tor-commits] [stem/master] Start initializing the asynchronous controller in the dedicated thread

atagar at torproject.org atagar at torproject.org
Thu Jul 16 01:28:59 UTC 2020


commit bc2c978a47e37b2f4a9b2ee581acec2e454fe0cd
Author: Illia Volochii <illia.volochii at gmail.com>
Date:   Sun Apr 26 21:46:41 2020 +0300

    Start initializing the asynchronous controller in the dedicated thread
---
 stem/control.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/stem/control.py b/stem/control.py
index 0105f9d4..3a687f1c 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -3908,9 +3908,15 @@ class Controller(_ControllerClassMethodMixin, _BaseControllerSocketMixin):
     self._asyncio_thread.setDaemon(True)
     self._asyncio_thread.start()
 
-    self._async_controller = AsyncController(control_socket, is_authenticated)
+    self._async_controller = self._init_async_controller(control_socket, is_authenticated)
     self._socket = self._async_controller._socket
 
+  def _init_async_controller(self, control_socket: 'stem.socket.ControlSocket', is_authenticated: bool) -> 'stem.control.AsyncController':
+    async def init_async_controller():
+      return AsyncController(control_socket, is_authenticated)
+
+    return asyncio.run_coroutine_threadsafe(init_async_controller(), self._asyncio_loop).result()
+
   def _execute_async_method(self, method_name: str, *args: Any, **kwargs: Any) -> Any:
     return asyncio.run_coroutine_threadsafe(
       getattr(self._async_controller, method_name)(*args, **kwargs),





More information about the tor-commits mailing list