Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26310
| Path | csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <andrea.crotti.0@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.018 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'suppose': 0.07; 'received :mail-lpp01m010-f46.google.com': 0.09; 'suggestions.': 0.09; 'def': 0.10; 'to:name:python-list': 0.15; '(also': 0.16; 'add(self,': 0.16; 'run(self):': 0.16; 'bit': 0.21; 'example': 0.23; 'seems': 0.23; 'pass': 0.25; 'message-id:@mail.gmail.com': 0.27; 'skip:_ 10': 0.29; 'class': 0.29; "i'm": 0.29; 'received:209.85.215.46': 0.30; 'running': 0.32; 'subject:data': 0.33; 'to:addr:python-list': 0.33; 'another': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'but': 0.36; "didn't": 0.36; 'skip:p 20': 0.36; 'why': 0.37; 'received:209': 0.37; 'data': 0.37; 'object': 0.38; 'some': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'world': 0.63; 'fun': 0.64 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=Dym2c3xhJYt5Fxrvsh2n98wn/b3/jz7tDuAEBLcE474=; b=M8xnI5kHHkf2qkPN9nEclGQyVhVwsB88CyXAV7U6VQvjvbA90vInDnS5yzDfBGqT6H cL6lGDgjV45r7yS028ej7/5nSnYqm7/4R26SGzM7Xt/sDRve4QE/pLe1z66NbsyJ2Rw+ DXSg+fyo4hq5uktMuuu9/LaCn1YejhUHQZnhnQrMldIE5P31NG+fimBynGZVpwWobWnK GlKYdHSZ3u7XQg8D2ktozgsSyWC3Q1kUtkoV2KupMJiHzujWgxn8pFDZr+U9DFfTu4tj 8l/mG67SQ9+JTOVOAM45LQfNdnbpzSNp558uz5pmDXFK75XUG5h6TGifrPgr81TZfsz7 AU3Q== |
| MIME-Version | 1.0 |
| Date | Tue, 31 Jul 2012 14:56:37 +0100 |
| Subject | Pass data to a subprocess |
| From | andrea crotti <andrea.crotti.0@gmail.com> |
| To | python-list <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| 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.2780.1343742999.4697.python-list@python.org> (permalink) |
| Lines | 39 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1343742999 news.xs4all.nl 6927 [2001:888:2000:d::a6]:56832 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:26310 |
Show key headers only | View raw
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?
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Pass data to a subprocess andrea crotti <andrea.crotti.0@gmail.com> - 2012-07-31 14:56 +0100
csiph-web