[tor-commits] [stem/master] Make `load_conf` and `save_conf` of `Controller` asynchronous

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


commit 8e8814552a68cd9926363e4953f969144667448a
Author: Illia Volochii <illia.volochii at gmail.com>
Date:   Tue Apr 21 22:40:45 2020 +0300

    Make `load_conf` and `save_conf` of `Controller` asynchronous
---
 stem/control.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/stem/control.py b/stem/control.py
index f8fae01e..93b7b924 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -3259,7 +3259,7 @@ class Controller(BaseController):
       self._request_cache = {}
       self._last_newnym = 0.0
 
-  def load_conf(self, configtext: str) -> None:
+  async def load_conf(self, configtext: str) -> None:
     """
     Sends the configuration text to Tor and loads it as if it has been read from
     the torrc.
@@ -3269,7 +3269,7 @@ class Controller(BaseController):
     :raises: :class:`stem.ControllerError` if the call fails
     """
 
-    response = stem.response._convert_to_single_line(self.msg('LOADCONF\n%s' % configtext))
+    response = stem.response._convert_to_single_line(async self.msg('LOADCONF\n%s' % configtext))
 
     if response.code in ('552', '553'):
       if response.code == '552' and response.message.startswith('Invalid config file: Failed to parse/validate config: Unknown option'):
@@ -3278,7 +3278,7 @@ class Controller(BaseController):
     elif not response.is_ok():
       raise stem.ProtocolError('+LOADCONF Received unexpected response\n%s' % str(response))
 
-  def save_conf(self, force: bool = False) -> None:
+  async def save_conf(self, force: bool = False) -> None:
     """
     Saves the current configuration options into the active torrc file.
 
@@ -3294,7 +3294,7 @@ class Controller(BaseController):
         the configuration file
     """
 
-    response = stem.response._convert_to_single_line(self.msg('SAVECONF FORCE' if force else 'SAVECONF'))
+    response = stem.response._convert_to_single_line(await self.msg('SAVECONF FORCE' if force else 'SAVECONF'))
 
     if response.is_ok():
       pass





More information about the tor-commits mailing list