Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Pass data to a subprocess

Reply
Thread Tools

Pass data to a subprocess

 
 
andrea crotti
Guest
Posts: n/a
 
      07-31-2012
I'm having fun in the world of multiprocessing, and I would like some
suggestions.

For example suppose I want to create many processes and pass them some
data to process (also why they are running).

I found many nice things (Pipe, Manager and so on), but actually even
this seems to work:


class MyProcess(Process):
def __init__(self):
Process.__init__(self)
self.ls = []

def __str__(self):
return str(self.ls)

def add(self, ls):
self.ls += ls

def run(self):
print("running the process in another subprocess")


def procs():
mp = MyProcess()
mp.start()
# with the join we are actually waiting for the end of the running time
mp.join()
mp.add([1,2,3])
mp.add([2,3,4])
print(mp)


Which is a bit surprising, because it means that I can pass data to an
object that is running on another process.
Is it because of some magic in the background and can I rely on that or
simply I didn't understand how it works?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Pass data to a subprocess andrea crotti Python 0 07-31-2012 03:26 PM
Re: Pass data to a subprocess Laszlo Nagy Python 0 07-31-2012 02:46 PM
Re: Pass data to a subprocess andrea crotti Python 0 07-31-2012 02:12 PM
how to import subprocess into my 'subprocess.py' file hiral Python 2 05-05-2010 12:56 PM
[Subprocess/Windows] subprocess module under Windows 98 Andreas Jung Python 2 11-02-2005 05:41 PM



Advertisments