[Twisted-Python] Example of a long-polling asynchronous web servic?

Glyph Lefkowitz glyph at twistedmatrix.com
Tue Oct 6 21:46:43 MDT 2009


On Tue, Oct 6, 2009 at 11:30 PM, Stephen Mattison <stephenmattison at gmail.com
> wrote:


> How can I implement this in Twisted?
>

You can use DeferredResource:


http://twistedmatrix.com/documents/8.2.0/api/twisted.web.util.DeferredResource.html

or you can return NOT_DONE_YET from Resource.render(), and hold on to the
request:


http://twistedmatrix.com/documents/8.2.0/api/twisted.web.resource.Resource.html#render

to leave the connection open until something happens.

For a more elaborate example of a long-polling server component, you could
see Nevow's Athena:

    http://www.divmod.org/trac/wiki/DivmodNevow/Athena

This does not implement JSON-RPC or XML-RPC, but it has lots of code for
managing the outstanding connection, which may give you some ideas.

-Glyph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20091006/d6c7dfd8/attachment.html>


More information about the Twisted-Python mailing list