[Twisted-Python] Control the number of parallel system calls

Matt Goodall matt at pollenation.net
Wed Sep 19 13:42:20 EDT 2007

Daniel de la Cuesta wrote:
> Hi,
> I am developing a video conversion server. To process the video
> conversion I use the method "getProcessOutput" to call "ffmpeg".
> The user upload the video using a HTTP POST and each video must be
> converted to 8 or 10 output formats.
> Currently, all the conversions for each video are processed in parallel,
> what I want to do is to control the number of parallel system calls to
> "ffmpeg". For example I only want 2 processes at the same time and when
> one of them finishes the next process start.
> How can I do that?
> Is there any function in Twisted that implements that?
> Thank you

I wrote something similar to what you want some time ago, although I
don't think I ever actually used it in the end. See attached module.

I included a __main__ section in the module that hopefully demonstrates
its use. Note that it was written as a Service so it needs starting,
hence the strange delayed call to startService before the reactor is run.

Basically, the thing is a service that makes the normal getProcessOutput
and getProcessValue utilities available. However, the execution requests
are queued and the maximum number of processes allowed to run is limited.

Hope it helps.

- Matt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: service.py
Type: text/x-python
Size: 1656 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20070919/c3bd9ae0/attachment.py 

More information about the Twisted-Python mailing list