[Twisted-Python] Twisted protocol as Django data source

Dave Britton dave at davebritton.com
Wed May 27 16:48:17 EDT 2009

I don't think the database option is a hack. Have twisted write the live
stream items into a ring-buffer SQL database table (eg. use records 1-100
over and over again), including a timestamp for each entry. Then your django
page can always retrieve the most current set of entries by SELECTing * from
the table in descending order by timestamp, which django is good at, staying
live with constant refreshing. There are no interprocess communication
pipes, broken sockets and timeouts etc. to screw up, no flaky javascript to
worry about, and the DBMS will handle the multiple simultaneous separate
data sources correctly. The central twisted application only has to keep
track of the buffer position. It's just not as much fun, though.

----- Original Message -----
From: "Dan" <charnedn at muohio.edu>
To: <twisted-python at twistedmatrix.com>
Sent: Wednesday, May 27, 2009 1:39 PM
Subject: [Twisted-Python] Twisted protocol as Django data source

> Hi all,
> I have an application written in Twisted which multiplexes data from a
> variety of pieces of specialized hardware, and I'd like to make the
> live stream of this information viewable through a webpage.
> Unfortunately, on our server, port 80 is already taken by an Apache +
> mod_python + Django stack with which we host a number of webpages.
> Ideally, I'd like to be able to write a quick Django app in which just
> import my Twisted protocol, connect to my network, and start streaming
> data. However, much googling has lead me to believe that this is
> unlikely to actually work. (Particularly,
> , which says that Twisted is simply not mod_python-friendly.)
> The options I've thought of include using Twisted's builtin web server
> a nonstandard port, mod_proxy, or writing a Django app which just
> polls a database repeatedly and altering my Twisted app so it
> repeatedly does an UPDATE. All of these solutions feel hacky to me, so
> I'd like to ask you, the list, how you'd go about doing this.
> Thanks,
> Dan
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

More information about the Twisted-Python mailing list