开发者

provide something similar to twitter's stream api with django

i would like to provide a streaming api to some data ala the twitter streaming api. i'm using django.

i believe just creating a generator for the data and retur开发者_如何学Cning that in a HttpResponse should be sufficient - encoding each item that is yielded into a javascript object.

would this work? is there a better way of doing this?


You need to think carefully about managing your server processes. A normal Django setup is not well suited for long-lived connections. It depends heavily on your specific configuration, but generally, if you keep servicing one connection your server is going to be less able to service new ones. A normal Django set up depends on finishing one connection before it moves on to the next one (although you would probably run several server processes to provide some concurrency).

I'm afraid I don't have any easy solutions for what you want to do. I guess I just have to say think about this carefully, and look at other libraries like Twisted. Twisted has support for streaming; see e.g. this link.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜