[tor-commits] [stem/master] Make Relay iterable to get circuits

atagar at torproject.org atagar at torproject.org
Wed Feb 7 19:44:51 UTC 2018


commit 94cd4204b86a21f21f73c28f40073841269f6503
Author: Damian Johnson <atagar at torproject.org>
Date:   Tue Feb 6 10:26:30 2018 -0800

    Make Relay iterable to get circuits
    
    Thought is: iterate over relays to get circuits, and iterate over
    circuits to get streams.
---
 stem/client/__init__.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/stem/client/__init__.py b/stem/client/__init__.py
index 5a9d09e6..3f8507e5 100644
--- a/stem/client/__init__.py
+++ b/stem/client/__init__.py
@@ -183,6 +183,11 @@ class Relay(object):
 
       return circ
 
+  def __iter__(self):
+    with self._orport_lock:
+      for circ in self._circuits.values():
+        yield circ
+
   def __enter__(self):
     return self
 





More information about the tor-commits mailing list