tags:

views:

88

answers:

3

hi all, I'm developing a system where a queue will be filled with millions of items

I need a process that reads items from the queue constantly and then sends those items out to registered clients.

I'm thinking about using twisted for this, having the queue reader be a twisted server listening on a tcp port then clients can connect on that port and when an item is pulled from the queue the server writes it out to all the clients.

Does that sound like something that twisted would be ideal for? Does anyone know of any sample code out there that may do something similar?

thanks

A: 

Maybe PB will do the trick?

lazy1
+1  A: 

Perspective Broker might be what you're looking for. If you dont know PB, think of it as XML-RPC but much more. You can invoke remote procedures (duh!), pass most of python objects around just to name two.

For your case, have a PB for clients. Twisted Server can invoke the remote doWork(myItem, myParameters). The Twisted Server will be a persistent process running which accumulates items in a queue. If you have millions (or even server tens) items, keep in mind of gracefully recovering in case of a crash. How about smartly backing stuff onto disk every now and then and reading this up when starting up ?

jeffjose
hi Jeff, the Twisted server will actually be pulling things off a persisted queue like beanstalkd. I'll take a look at perspective broker, thanks!
A: 

Twisted and PB would be a great fit for this - there's a bunch of good references on Stack:

http://stackoverflow.com/questions/1888139/python-twisted-where-to-start/1888748#1888748

Ben Hughes