[Twisted-Python] Using service.Application
Jp Calderone
exarkun at intarweb.us
Mon Dec 15 08:27:19 EST 2003
On Mon, Dec 15, 2003 at 10:14:44AM -0000, Richard.Townsend at edl.uk.eds.com wrote:
> I had the following demo script for Twisted 1.0.6:
>
> #-----------------
> [snip server code]
> #-----------------
>
> This works OK with the following client:
>
> #-----------------
> [snip client code]
> #-----------------
>
> However, under Twisted 1.1.1 this raises:
> exceptions.DeprecationWarning: twisted.internet.app is deprecated,
> use twisted.application instead.
>
> So I tried to create a new version of the server:
>
> #-----------------
> [snip]
> if __name__ == '__main__':
>
> f = sys.stdout
> log.startLogging(f)
>
> root = Simple()
> site = server.Site(root)
> application = service.Application('web')
> sc = service.IServiceCollection(application)
> i = internet.TCPServer(8080, site)
> i.setServiceParent(sc)
> reactor.run()
> #-----------------
>
> But now my client gives this:
>
> Error: [Failure instance: Traceback:
> twisted.internet.error.ConnectionRefusedError,
> Connection was refused by other side: 22: Invalid argument.
> ]
>
> I am running Python 2.3.2 on HP-UX 11i.
>
> Can anybody advise what is happening here?
>
Your new version isn't actually starting up any of your services. Two
ways to address this: use twisted.internet.app.startApplication and
twisted.internet.app.runReactorWithLogging (these are what "twistd" calls
internally) instead of reactor.run, or get rid of the __name__ check and the
reactor.run() call, and use "twistd -y <your file>" to run the server.
Jp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20031215/cd66dfb3/attachment.pgp
More information about the Twisted-Python
mailing list