[tor-commits] [stem/master] Fix stem.descriptor.remote deadlock

atagar at torproject.org atagar at torproject.org
Wed Jul 22 01:51:23 UTC 2020


commit 02f74f44f09efa9f854f830ae2a2f28514040e1d
Author: Damian Johnson <atagar at torproject.org>
Date:   Tue Jul 21 17:52:44 2020 -0700

    Fix stem.descriptor.remote deadlock
    
    Oops! While writing our Synchronous class I made our Query directly stop its
    loop, ending its loop thread. Our class internally expects our thread attribute
    to be None when its terminated, and as such wouldn't resume.
    
    To reproduce the deadlock I used the following script...
    
      import stem.descriptor.remote
    
      downloader = stem.descriptor.remote.DescriptorDownloader(validate = True)
      consensus_query = downloader.get_consensus()
      consensus_query.run()
    
      consensus = list(consensus_query)
      print('count: %s' % len(consensus))
---
 stem/descriptor/remote.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/stem/descriptor/remote.py b/stem/descriptor/remote.py
index 2c97c361..96ffceed 100644
--- a/stem/descriptor/remote.py
+++ b/stem/descriptor/remote.py
@@ -475,7 +475,7 @@ class Query(Synchronous):
       return [desc async for desc in self._run(suppress)]
     finally:
       if stop:
-        self._loop.call_soon_threadsafe(self._loop.stop)
+        self.stop()
 
   async def _run(self, suppress: bool) -> AsyncIterator[stem.descriptor.Descriptor]:
     with self._downloader_lock:





More information about the tor-commits mailing list