Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #15776

Re: Multiple threads

From Christian Heimes <lists@cheimes.de>
Subject Re: Multiple threads
Date 2011-11-16 16:01 +0100
References <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23>
Newsgroups comp.lang.python
Message-ID <mailman.2769.1321455690.27778.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Multiple threads Eduardo Oliva <dutche@gmail.com> - 2011-11-16 05:48 -0800
  Re: Multiple threads Chris Angelico <rosuav@gmail.com> - 2011-11-17 00:55 +1100
  Re: Multiple threads Henrik Faber <hfaber@invalid.net> - 2011-11-16 15:07 +0100
  Re: Multiple threads Christian Heimes <lists@cheimes.de> - 2011-11-16 16:01 +0100
  Re: Multiple threads Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-11-16 17:45 +0100
    Re: Multiple threads Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-11-16 16:38 -0800
  Re: Multiple threads Dave Angel <d@davea.name> - 2011-11-16 12:27 -0500
  Re: Multiple threads Michael Hunter <tahoemph@gmail.com> - 2011-11-16 09:55 -0800
  Re: Multiple threads Dave Angel <d@davea.name> - 2011-11-16 13:06 -0500
  Re: Multiple threads Dave Angel <d@davea.name> - 2011-11-16 13:30 -0500
  Re: Multiple threads Miki Tebeka <miki.tebeka@gmail.com> - 2011-11-16 12:50 -0800

csiph-web