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


Groups > comp.lang.python > #15795

Re: Multiple threads

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Multiple threads
Date 2011-11-16 16:38 -0800
Organization > Bestiaria Support Staff <
References <31766634.4.1321451296410.JavaMail.geo-discussion-forums@yqcm23> <ja0pbf$4em$1@r03.glglgl.gl>
Newsgroups comp.lang.python
Message-ID <mailman.2787.1321490302.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, 16 Nov 2011 17:45:29 +0100, Thomas Rachel
<nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de>
declaimed the following in gmane.comp.python.general:

> 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.
> >
> > Any help would be great.
> 
> I'm not sure if you need threads at all: if you launch a process with 
> subprocess, it runs and you only would have to wait() for it. The same 
> can be done with two processes.
>
	In the larger problem description, though, it is mentioned that the
actual conversion is done by spawning an "ffmpeg" command... So why run
a Python process whose only activity is to spawn a process that does the
real work.


	Using a pair (or however many) worker threads which feed off a
shared Queue for the files to convert, and then spawn the ffmpeg
process(es) and wait, is likely simpler than trying to feed data to
external processes.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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