I'm trying to write a small wsgi application which will put some objects to an external queue after each request. I want to make this in batch, ie. make the webserver put the object to a buffer-like structure in memory, and another thread and/or process for sending these objects to the queue in batch, when buffer is big enough or after certain timeout, and clearing the buffer. I don't want to be in NIH syndrome and not want to bother with threading stuff, however I could not find a suitable code for this job. Any suggestions?
+5
A:
Examine http://www.python.org/doc/2.5.2/lib/module-Queue.html to see if it meets your needs.
S.Lott
2009-01-04 02:03:01
beat me by 16 seconds to the same answer. I think that's what he wants too, but couldn't quite figure it out.
llimllib
2009-01-04 02:04:03
Here is what I like most about Python: the 80% of what you're going to implement is already out there. Often, even in the standard library.
Federico Ramponi
2009-01-04 03:48:55
And this question has already been asked on SO. http://stackoverflow.com/questions/394500/is-there-a-simple-way-in-python-to-create-a-file-which-can-be-written-to-in-one-t
S.Lott
2009-01-04 13:09:38
+2
A:
Since you write "thread and/or process", see also multiprocessing.Queue and multiprocessing.JoinableQueue from 2.6. Those are interprocess variants of Queue.
Constantin
2009-01-04 02:48:00