[Twisted-Python] strange twistd behaviour

Stéphane Brault stephane_brault at yahoo.fr
Wed Jul 26 06:58:01 MDT 2006


Hi,
 I created a twisted server but when I run it with twistd I don't get the same behaviour
 that I get when I use reactor.run()
 Here what I do with reactor:
 
 import communication.update
  import communication.updateXMLRPC
 from twisted.internet import reactor
  from twisted.web import resource, server as webserver
  
  communications = communication.update.communications("mysql://....")
  comXMLRPC = communication.updateXMLRPC.communicationsXMLRPC(communications)
  rootResource = resource.Resource()
  rootResource.putChild('RPC2', comXMLRPC)
 reactor.listenTCP(8000, webserver.Site(rootResource))
 reactor.run()
 
 
 Here is the server:
 
 import communication.update
 import communication.updateXMLRPC
 from twisted.application import service, internet
 from twisted.web import resource, server as webserver
 
 communications = communication.update.communications("mysql://....")
 comXMLRPC = communication.updateXMLRPC.communicationsXMLRPC(communications)
 rootResource = resource.Resource()
 rootResource.putChild('RPC2', comXMLRPC)
 webService = internet.TCPServer(8000, webserver.Site(rootResource))
 webService.setName('web')
 application = service.Application('communication')
 webService.setServiceParent(application)
 
 The communications class looks like that:
 
 class communications(object):
     
     def __init__(self, url):
         self.databaseReady = False
         self.databaseBroker = DatabaseBroker(url)
         d = self.databaseBroker.startup()  #line 1
         d.addCallback(self.serverReady).addErrback(self.serverError) #line 2
         
         
     def serverReady(self, result):
         self.databaseReady = True
 
     def serverError(self, error):
 ....
 
 The server works fine on WinXP, the code with the reactor works fine everywhere but the server, called by twistd -y /../server.py,
 starts but has problems with line 1 and line 2 (doesn't seem to call them) on my debian distribution (3.1).
 Any hints ?
 
 Thanks,
 
 Stéphane






More information about the Twisted-Python mailing list