Open atagar opened 3 years ago
Unfortunately I moved on from Tor before finishing this. My plan was to revert the Controller back to being synchronous, but with an async msg method and asynchronous socket objects (that is to say, async low level components with a synchronous wrapper). I spent a month on this but it's not yet done...
https://gitweb.torproject.org/user/atagar/stem.git/log/?h=bug77
To transparently support both synchronous and asynchronous usage we use metaprogrmming. Basically, our mixin matches method calls to the context type we run within.
When a synchronous controller is used within an event handler we mistakenly treat it as being asynchronous. For example...
The trouble here is that our listener invokes within our controller, which is an asynchronous context. Needless to say, this is confusing as hell.
I'm going to revisit and likely remove our asyncio metaprogramming. It's complicated, breaks type checks, and liable to keep causing problems. Pitching this on the python list and stack overflow I get the sense that this isn't a promising approach long term.