Twisted

From Solipsis

Twisted (http://twistedmatrix.com/) is a generic framework for Python that is meant to ease the development of network-based services.

Table of contents

Interesting stuff in Twisted

  • event loop abstraction (reactor-based) that simplifies asynchronous event processing
  • XMLRPC abstraction: less simple than Python's xmlrpclib, perhaps more powerful
  • SSL, authentication: can be useful for secure XMLRPC between node and navigator

Potential problems with Twisted

  • download footprint (not too much of an issue, depends on what we deem acceptable for Windows download size)
  • problems making Twisted and wxPython word hand in hand : see this message (http://mail.python.org/pipermail/python-win32/2004-July/002116.html), this one (http://mail.python.org/pipermail/python-list/2004-October/245730.html)

Twisted + wxPython

The only sensible solution is to have two separate event loops, thus two threads:

  • the main thread runs the wxPython event loop (app.MainLoop())
  • a child thread runs the Twisted event loop (##reactor.run(installSignalHandlers=0)##); this thread can be set in "daemon" mode (mythread.setDaemon(True)) so that it is automatically killed when the main thread exits

I've written an an example of the cohabitation of WxPython and Twisted.

There is another recipe here (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/181780).

Other tools

Pyro (http://pyro.sourceforge.net/) seems to be a nice library to completely abstract remote object instantiation in Python.

related web sites