On Sat, Dec 06, 2008 at 11:19:08AM +0100, slush wrote: > > > > use multiple threads (one to do the connect, and one to listen to Tor > > controller events and assign the stream to the circuit) > > > You are a genius! (An I'm and an idiot because I didn't found this solution > by self!) > > I will post final solution after it will works. Currently there is at least > one problem, because after calling attach_stream from another thread (and > Tor returns me SENTCONNECT event), calling of socket.connect() is still > blocking and Tor never send me SUCCEEDED (which I expect as confirmation of > SENTCONNECT). I'm right? What can I do wrong? > > Current situation is: > > 1) Create circuit (main thread) -- OK > 2) Call socket.connect() (main thread) -- OK > 3) call ctl.attach_stream() from Tor callback handler (it is separate > thread) instead of waiting on stream_id in main thread. It causes to > SENTCONNECT event (with correct stream an circ id), but main thread is still > blocked and Im missing SUCCEEDED event as confirmation... > 4) Then, socket.connect() should return socket in main thread, but it never > happen. > > Marek,
You may also want to look at blossom.py, which provides an example of control of Tor circuits using multiple threads. https://svn.torproject.org/svn/blossom/trunk/blossom.py It may be a bit out-of-date. Geoff

