Re: executing multiple functions in background simultaneously

2009-01-14 Thread Steve Holden
Jean-Paul Calderone wrote: > On Wed, 14 Jan 2009 17:11:44 -0800, Catherine Moroney > wrote: >> [snip] >>> >>> The easy thing is to use a Queue object. The background thread uses >>> .put() to place a computed result on the QUeue and the caller uses >>> .get() to read from the queue. There's an ass

Re: executing multiple functions in background simultaneously

2009-01-14 Thread Cameron Simpson
On 14Jan2009 17:11, Catherine Moroney wrote: > Cameron Simpson wrote: >> On 14Jan2009 15:50, Catherine Moroney >> wrote: >>> James Mills wrote: On Wed, Jan 14, 2009 at 11:02 AM, Catherine Moroney wrote: > I would like to spawn off multiple instances of a function > and run the

Re: executing multiple functions in background simultaneously

2009-01-14 Thread James Mills
Speaking of Threading .. http://codepad.org/dvxwAphE Just a really interesting way of doing this :) cheers James -- -- "Problems are solved by method" -- http://mail.python.org/mailman/listinfo/python-list

Re: executing multiple functions in background simultaneously

2009-01-14 Thread Catherine Moroney
On Jan 14, 2009, at 5:20 PM, Jean-Paul Calderone wrote: On Wed, 14 Jan 2009 17:11:44 -0800, Catherine Moroney wrote: [snip] The easy thing is to use a Queue object. The background thread uses .put() to place a computed result on the QUeue and the caller uses .get() to read from the queue. T

Re: executing multiple functions in background simultaneously

2009-01-14 Thread Jean-Paul Calderone
On Wed, 14 Jan 2009 17:11:44 -0800, Catherine Moroney wrote: [snip] The easy thing is to use a Queue object. The background thread uses .put() to place a computed result on the QUeue and the caller uses .get() to read from the queue. There's an assortment of other ways too. Cheers, Thank y

Re: executing multiple functions in background simultaneously

2009-01-14 Thread Catherine Moroney
Cameron Simpson wrote: On 14Jan2009 15:50, Catherine Moroney wrote: James Mills wrote: On Wed, Jan 14, 2009 at 11:02 AM, Catherine Moroney wrote: I would like to spawn off multiple instances of a function and run them simultaneously and then wait until they all complete. [...] Try using th

Re: executing multiple functions in background simultaneously

2009-01-14 Thread Aaron Brady
On Jan 14, 6:00 pm, Cameron Simpson wrote: > On 14Jan2009 15:50, Catherine Moroney > wrote: > > > James Mills wrote: > >> On Wed, Jan 14, 2009 at 11:02 AM, Catherine Moroney > >> wrote: > >>> I would like to spawn off multiple instances of a function > >>> and run them simultaneously and then w

Re: executing multiple functions in background simultaneously

2009-01-14 Thread Cameron Simpson
On 14Jan2009 15:50, Catherine Moroney wrote: > James Mills wrote: >> On Wed, Jan 14, 2009 at 11:02 AM, Catherine Moroney >> wrote: >>> I would like to spawn off multiple instances of a function >>> and run them simultaneously and then wait until they all complete. [...] >> Try using the python st

Re: executing multiple functions in background simultaneously

2009-01-14 Thread Catherine Moroney
James Mills wrote: On Wed, Jan 14, 2009 at 11:02 AM, Catherine Moroney wrote: I would like to spawn off multiple instances of a function and run them simultaneously and then wait until they all complete. Currently I'm doing this by calling them as sub-processes executable from the command-line.

Re: executing multiple functions in background simultaneously

2009-01-14 Thread brooklineTom
> The disadvantage of threads in Python (CPython, actually) is that > there's the GIL (Global Interpreter Lock), so you won't get any speed > advantage if the threads are mostly processor-bound. On a single processor machine with compute-bound threads, I don't the GIL is the bottleneck. No matter

Re: executing multiple functions in background simultaneously

2009-01-14 Thread Aaron Brady
On Jan 13, 7:02 pm, Catherine Moroney wrote: > Hello everybody, > > I know how to spawn a sub-process and then wait until it > completes.  I'm wondering if I can do the same thing with > a Python function. > > I would like to spawn off multiple instances of a function > and run them simultaneously

Re: executing multiple functions in background simultaneously

2009-01-13 Thread Michele Simionato
On Jan 14, 2:02 am, Catherine Moroney wrote: > Hello everybody, > > I know how to spawn a sub-process and then wait until it > completes.  I'm wondering if I can do the same thing with > a Python function. > > I would like to spawn off multiple instances of a function > and run them simultaneously

Re: executing multiple functions in background simultaneously

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 11:35 AM, MRAB wrote: > The disadvantage of threads in Python (CPython, actually) is that > there's the GIL (Global Interpreter Lock), so you won't get any speed > advantage if the threads are mostly processor-bound. The OP didn't really say what this function does :) *sig

Re: executing multiple functions in background simultaneously

2009-01-13 Thread MRAB
James Mills wrote: On Wed, Jan 14, 2009 at 11:02 AM, Catherine Moroney wrote: I would like to spawn off multiple instances of a function and run them simultaneously and then wait until they all complete. Currently I'm doing this by calling them as sub-processes executable from the command-lin

Re: executing multiple functions in background simultaneously

2009-01-13 Thread James Mills
On Wed, Jan 14, 2009 at 11:02 AM, Catherine Moroney wrote: > I would like to spawn off multiple instances of a function > and run them simultaneously and then wait until they all complete. > Currently I'm doing this by calling them as sub-processes > executable from the command-line. Is there a w

executing multiple functions in background simultaneously

2009-01-13 Thread Catherine Moroney
Hello everybody, I know how to spawn a sub-process and then wait until it completes. I'm wondering if I can do the same thing with a Python function. I would like to spawn off multiple instances of a function and run them simultaneously and then wait until they all complete. Currently I'm doing