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

[tor-commits] [stem/master] Return the previous behavior of `_get_with_timeout`



commit 3431c5cba5ead275f359d2785cd5cc252e5b495d
Author: Illia Volochii <illia.volochii@xxxxxxxxx>
Date:   Tue Apr 21 21:44:13 2020 +0300

    Return the previous behavior of `_get_with_timeout`
---
 stem/control.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/stem/control.py b/stem/control.py
index 67fb6a47..d0cbb34a 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -2085,7 +2085,7 @@ class Controller(BaseController):
         return None  # not waiting, so nothing to provide back
       else:
         while True:
-          event = await _get_with_timeout(hs_desc_content_queue, timeout)
+          event = await _get_with_timeout(hs_desc_content_queue, timeout, start_time)
 
           if event.address == address:
             if event.descriptor:
@@ -2094,7 +2094,7 @@ class Controller(BaseController):
               # no descriptor, looking through HS_DESC to figure out why
 
               while True:
-                event = await _get_with_timeout(hs_desc_queue, timeout)
+                event = await _get_with_timeout(hs_desc_queue, timeout, start_time)
 
                 if event.address == address and event.action == stem.HSDescAction.FAILED:
                   if event.reason == stem.HSDescReason.NOT_FOUND:
@@ -3992,7 +3992,12 @@ async def _get_with_timeout(event_queue: queue.Queue, timeout: float, start_time
   Pulls an item from a queue with a given timeout.
   """
 
+  if timeout:
+    time_left = timeout - (time.time() - start_time)
+  else:
+    time_left = None
+
   try:
-    return await asyncio.wait_for(event_queue.get(), timeout=timeout)
+    return await asyncio.wait_for(event_queue.get(), timeout=time_left)
   except asyncio.TimeoutError:
     raise stem.Timeout('Reached our %0.1f second timeout' % timeout)



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