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

[tor-commits] [stem/master] connect() broke Controller's iterator methods



commit e1137067509f005504731157297096f9890b5f7d
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Fri Oct 2 15:52:48 2020 -0700

    connect() broke Controller's iterator methods
    
    Damn I need to rewrite our connection module. As indicated by the TODO comment,
    this method copies some of Synchronous' init. No surprise then that when I
    fixed Synchronous' iterators the fix didn't get propagated here.
    
    Caught thanks to toralf noticing that our relay_connections.py example didn't
    work...
    
      % python3.7 relay_connections.py
       0.4.5.0-alpha-dev   uptime: 14:27   flags: none
    
      Traceback (most recent call last):
        File "relay_connections.py", line 130, in <module>
          main()
        File "relay_connections.py", line 50, in main
          for desc in controller.get_network_statuses():
      TypeError: 'async_generator' object is not iterable
---
 stem/connection.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/stem/connection.py b/stem/connection.py
index 68cfda45..005949ef 100644
--- a/stem/connection.py
+++ b/stem/connection.py
@@ -305,7 +305,7 @@ def connect(control_port: Tuple[str, Union[str, int]] = ('127.0.0.1', 'default')
         pass
       elif isinstance(func, unittest.mock.Mock) and inspect.iscoroutinefunction(func.side_effect):
         setattr(connection, name, functools.partial(connection._run_async_method, name))
-      elif inspect.ismethod(func) and inspect.iscoroutinefunction(func):
+      elif inspect.ismethod(func) and (inspect.iscoroutinefunction(func) or inspect.isasyncgenfunction(func)):
         setattr(connection, name, functools.partial(connection._run_async_method, name))
 
     return connection



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