[Twisted-Python] design of twisted application

Kurt Spindler kespindler at gmail.com
Wed Feb 2 00:15:07 MST 2011


Hey,

I am trying to design a twisted application, (I'm pretty new to twisted and
networking in general) and I feel like I'm not approaching it quite the
right way and would appreciate your feedback. First part, is that I am
trying to couple twisted with an existing graphics-type application, that
already has it's own main loop, etc. Meaning, I need to be running other
python code while I have the reactor running. Is the solution threading?



  f = MyFactory()

  reactor.connectTCP("localhost",22223,f)

  t = threading.Thread(target=reactor.run)

  t.run()

  runOtherCodeConcurrently()


Is there a better solution? Second question is that, in that other bunch of
code, I need to be able to write things to the socket. How can I access the
instance of my protocol subclass that is used by the factory, so I can make
protocolInstance.transport.write type calls? Or am I thinking about this is
a completely wrong way?

Thank you very much for your help!

Kurt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20110202/52c4c61e/attachment.html>


More information about the Twisted-Python mailing list