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

[tor-commits] [stem/master] Use run() for Query example



commit 0a8b47e85f8064a559c3273ea8707fbc27657b71
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Mon Nov 12 09:34:30 2018 -0800

    Use run() for Query example
    
    Oops. As mentioned by irl the surrounding text talks about using run() so our
    demonstration should too. This example was correct (due to its 'block = True'
    argument), but better to show what we say we show.
    
      https://trac.torproject.org/projects/tor/ticket/28400
---
 stem/descriptor/remote.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/stem/descriptor/remote.py b/stem/descriptor/remote.py
index 47af2232..4ec83199 100644
--- a/stem/descriptor/remote.py
+++ b/stem/descriptor/remote.py
@@ -221,17 +221,16 @@ class Query(object):
 
     query = Query(
       '/tor/server/all',
-      block = True,
       timeout = 30,
     )
 
     print('Current relays:')
 
-    if not query.error:
-      for desc in query:
+    try:
+      for desc in Query('/tor/server/all', 'server-descriptor 1.0'):
         print(desc.fingerprint)
-    else:
-      print('Unable to retrieve the server descriptors: %s' % query.error)
+    except Exception as exc:
+      print('Unable to retrieve the server descriptors: %s' % exc)
 
   ... while iterating fails silently...
 

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