[Twisted-Python] twisted daemonize problem

Marco Giusti marco.giusti at gmail.com
Mon Nov 8 15:08:08 EST 2010

On Mon, Nov 08, 2010 at 01:50:38PM -0500, Neal Becker wrote:
> I seem to have things working OK with twistd.
> My app is a batch scheduling system that listens for commands via xmlrpc.  
> It is very simple at this point, and I'm attaching it.  I would welcome any 
> suggestions for improvement, since I'm a newb to twisted, and a lot of this 
> was guesswork.
> task.py is a seperate file because otherwise pickle doesn't work.  t6.tac is 
> the server, and a toy client is client4.py.

If I could you give a suggestion on how to structure the server side of
your program:

The ``Task`` class in a separate file, this is fine, clients could
import the file without the need to import the non useful, for the
client, server code.

All the server logic in a file and a third file for the tap, here a
possible structure:

		|- client.py
		|- server.py
		`- task.py
		`- plugins/
			`- procxmlrpc_plugin.py

Here the simplified code, all the remaining code goes into ``server.py``

	from procxmlrpc.server import Spawner

	from twisted.web import server
	from twisted.application import service, internet

	application = service.Application("Demo application")
	spawn_server = server.Site(Spawner())
	service = internet.TCPServer(7080, spawn_server)


Nessuno come me si è creato una società reale evocando delle ombre; al
punto che la vita dei miei ricordi assorbe il sentimento della mia
vita reale.
				-- René de Chateaubriand, Mémoires d'Outre-tombe

More information about the Twisted-Python mailing list