Multiple threads
Christian Heimes
lists at cheimes.de
Wed Nov 16 10:01:15 EST 2011
Am 16.11.2011 14:48, schrieb Eduardo Oliva:
> Hello, I have a py script that reads for all "m2ts" video files and convert them to "mpeg" using ffmpeg with command line.
>
> What I want to do is:
>
> I need my script to run 2 separated threads, and then when the first has finished, starts the next one....but no more than 2 threads.
> I know that Semaphores would help with that.
> But the problem here is to know when the thread has finished its job, to release the semaphore and start another thread.
I suggest a slight different approach: use a queue [1] and create two
worker threads that consume the queue. You don't need multiprocessing
because you are already using multiple processes here (one Python and
two ffmpeg processes).
Christian
[1] http://docs.python.org/library/queue.html
More information about the Python-list
mailing list