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


Groups > comp.lang.python > #86252

multiprocessing module best practices?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <calderon.christian760@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'tutorial': 0.03; 'patterns': 0.04; 'classes,': 0.05; 'importing': 0.05; 'ugly': 0.07; 'statements': 0.09; 'subject:module': 0.09; 'url:github': 0.09; 'wrote': 0.14; 'imo.': 0.16; 'pythonic': 0.16; 'subclass': 0.16; 'subject:skip:m 10': 0.16; 'url:py': 0.16; 'appropriate': 0.16; 'module': 0.19; 'trying': 0.19; 'written': 0.21; 'code,': 0.22; 'example': 0.22; 'import': 0.22; "shouldn't": 0.24; 'sort': 0.25; 'certain': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '(my': 0.31; 'go.': 0.31; 'piece': 0.31; 'them?': 0.31; 'with,': 0.31; 'figure': 0.32; 'run': 0.32; 'community': 0.33; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'curious': 0.36; 'subject:?': 0.36; 'should': 0.36; 'process,': 0.38; 'tools,': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'most': 0.60; 'skip:n 10': 0.64; 'here': 0.66; 'url:master': 0.84; 'hate': 0.91; 'incredibly': 0.96
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=Qz9xaN+cjEnNCDYDRFYaOeAneEITK+KPqfwgxw5UM6M=; b=qDeaBLSYSTYjcl/UmKDeMPUSh62jrXiRxJXrT1yB9JOa+e1Ms6jsLducH0bIm2pPmU XhAkRFtoI7b5H0FOEvO8bCLDGKqYXx6uFZUvpPCpL+HRI+8/BArgc2u4Yq8vrbXalInP v8kIERPej9PIZvU8JXO1geZASR4t8OjQpFOrj1dYURs1XW5werpyGIqBzSFht++DV8o9 +cqzcLZk0ZfLYIURso1bFmtrZX9ZYZcVAE1AiNGThfBzoYrNfbJYXuTFGWBz9Ujj+dhw jMDTeQixSqiLpfGPo46vnMTCxv8B29p90e6w3lQFY7b5DPbUIr901Xl7xHwfuai9S/HD utMw==
MIME-Version 1.0
X-Received by 10.236.30.233 with SMTP id k69mr10823542yha.123.1424715966398; Mon, 23 Feb 2015 10:26:06 -0800 (PST)
Date Mon, 23 Feb 2015 10:26:06 -0800
Subject multiprocessing module best practices?
From Christian Calderon <calderon.christian760@gmail.com>
To python-list@python.org
Content-Type multipart/alternative; boundary=001a11c20276154966050fc589b0
X-Mailman-Approved-At Mon, 23 Feb 2015 19:40:30 +0100
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.19093.1424716831.18130.python-list@python.org> (permalink)
Lines 48
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1424716831 news.xs4all.nl 2844 [2001:888:2000:d::a6]:40468
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:86252

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Is there a good blog or tutorial on when it is most appropriate to use the
Process vs Pool classes, and when you should subclass either of them? I
have written a few programs using these tools, and each time I have to sort
of make up my own design patterns as I go. I want to know what the
community thinks is the most pythonic use of the multiprocessing module (I
could just subclass Process every single time, why shouldn't I?)

I'm also curious about when I should be importing modules in the main
module to use in a Process, and when I should import the module inside the
run method/target function. Certain modules just won't work unless I import
it in the Process; I hate having a ton of import statements inside my
functions, but I also hate having to guess-and-check just to figure out
which modules I can import outside the function. And it is just kinda ugly
to have import statements at multiple parts of the same piece of code, IMO.

Here is an example of something I wrote that feels kinda funky (my excuse
is that the code-base I was working with was incredibly funky to begin
with, and I was trying to make a small corner of it nicer/actually work.):
    https://github.com/zack-bitcoin/augur-core/blob/master/database.py

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

multiprocessing module best practices? Christian Calderon <calderon.christian760@gmail.com> - 2015-02-23 10:26 -0800

csiph-web