[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Drop query 'stop' argument



commit 278e7ee8abf83a79f107bff20cd0e654c0e4977e
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Tue Jul 21 18:06:59 2020 -0700

    Drop query 'stop' argument
    
    I added a 'stop' argument to our Query's run method because our Synchronous
    class couldn't be used after it was discontinued. However, it now resumes
    itself upon further async method calls so we do not need to avoid stoppages.
---
 stem/descriptor/remote.py      | 11 ++---------
 test/unit/descriptor/remote.py |  2 +-
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/stem/descriptor/remote.py b/stem/descriptor/remote.py
index 96ffceed..2912134c 100644
--- a/stem/descriptor/remote.py
+++ b/stem/descriptor/remote.py
@@ -447,14 +447,12 @@ class Query(Synchronous):
         loop = asyncio.get_event_loop()
         self._downloader_task = loop.create_task(self._download_descriptors(self.retries, self.timeout))
 
-  async def run(self, suppress: bool = False, stop: bool = True) -> List['stem.descriptor.Descriptor']:
+  async def run(self, suppress: bool = False) -> List['stem.descriptor.Descriptor']:
     """
     Blocks until our request is complete then provides the descriptors. If we
     haven't yet started our request then this does so.
 
     :param suppress: avoids raising exceptions if **True**
-    :param stop: terminates the resources backing this query if **True**,
-      further method calls will raise a RuntimeError
 
     :returns: list for the requested :class:`~stem.descriptor.__init__.Descriptor` instances
 
@@ -467,15 +465,10 @@ class Query(Synchronous):
         * :class:`~stem.DownloadFailed` if our request fails
     """
 
-    # TODO: We should replace our 'stop' argument with a new API design prior
-    # to release. Self-destructing this object by default for synchronous users
-    # is quite a step backward, but is acceptable as we iterate on this.
-
     try:
       return [desc async for desc in self._run(suppress)]
     finally:
-      if stop:
-        self.stop()
+      self.stop()
 
   async def _run(self, suppress: bool) -> AsyncIterator[stem.descriptor.Descriptor]:
     with self._downloader_lock:
diff --git a/test/unit/descriptor/remote.py b/test/unit/descriptor/remote.py
index 3facd6a5..6b9ca3ad 100644
--- a/test/unit/descriptor/remote.py
+++ b/test/unit/descriptor/remote.py
@@ -135,7 +135,7 @@ class TestDescriptorDownloader(unittest.TestCase):
   def test_reply_header_data(self):
     query = stem.descriptor.remote.get_server_descriptors('9695DFC35FFEB861329B9F1AB04C46397020CE31', start = False)
     self.assertEqual(None, query.reply_headers)  # initially we don't have a reply
-    query.run(stop = False)
+    query.run()
 
     self.assertEqual('Fri, 13 Apr 2018 16:35:50 GMT', query.reply_headers.get('Date'))
     self.assertEqual('application/octet-stream', query.reply_headers.get('Content-Type'))



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits