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


Groups > comp.lang.python > #15776

Re: Multiple threads

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'threads,': 0.07; 'python': 0.08; 'consume': 0.09; 'finished,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'semaphores': 0.16; 'subject:threads': 0.16; 'thread.': 0.16; 'convert': 0.19; 'suggest': 0.20; 'header:In-Reply-To:1': 0.23; 'starts': 0.23; 'command': 0.24; 'script': 0.28; 'problem': 0.29; 'queue': 0.30; 'separated': 0.30; 'threads': 0.30; 'threads.': 0.30; 'worker': 0.30; 'url:library': 0.30; 'to:addr:python-list': 0.32; 'header :User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.33; 'url:python': 0.35; 'thread': 0.36; 'another': 0.36; 'but': 0.37; 'two': 0.37; 'using': 0.37; 'received:org': 0.37; 'run': 0.38; 'hello,': 0.38; 'url:org': 0.38; 'finished': 0.38; 'url:docs': 0.38; 'help': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; 'release': 0.40; 'files': 0.40; 'more': 0.60; 'here': 0.65; '(one': 0.73; 'eduardo': 0.84; 'schrieb': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Christian Heimes <lists@cheimes.de>
Subject Re: Multiple threads
Date Wed, 16 Nov 2011 16:01:15 +0100
References <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host smtp.semantics.de
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
In-Reply-To <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23>
X-Enigmail-Version 1.4a1pre
OpenPGP id=AD16AB1B; url=http://cheimes.de/heimes.asc
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2769.1321455690.27778.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1321455690 news.xs4all.nl 6951 [2001:888:2000:d::a6]:40252
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:15776

Show key headers only | 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