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


Groups > comp.lang.python > #37081

Re: Question related to multiprocessing.Process

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Question': 0.07; 'wang': 0.07; 'python': 0.09; 'idea?': 0.09; 'imports': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:related': 0.09; 'terminate.': 0.09; 'terry': 0.09; 'way:': 0.09; 'def': 0.10; 'advance.': 0.15; 'sat,': 0.15; 'instantiates': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'run(self):': 0.16; 'win7': 0.16; 'wrote:': 0.17; 'documented': 0.17; 'module,': 0.17; 'jan': 0.18; 'windows': 0.19; 'module': 0.19; 'import': 0.21; 'skip:_ 20': 0.22; 'programming': 0.23; 'command': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'header:X-Complaints-To:1': 0.28; 'chris': 0.28; 'routine': 0.29; 'starts': 0.29; 'skip:_ 10': 0.29; 'class': 0.29; "i'm": 0.29; 'print': 0.32; 'to:addr:python-list': 0.33; 'code:': 0.33; 'hi,': 0.33; 'another': 0.33; 'thanks': 0.34; 'pm,': 0.35; 'received:org': 0.36; 'but': 0.36; 'should': 0.36; 'skip:p 20': 0.36; 'keeps': 0.37; 'does': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'your': 0.60; "you'll": 0.62; 'protect': 0.69; 'prompt': 0.78; '2013': 0.84; 'received:fios.verizon.net': 0.84; 'repeat.': 0.84; 'rinse': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: Question related to multiprocessing.Process
Date Sat, 19 Jan 2013 06:27:33 -0500
References <6816f48f-753f-4ae3-be79-3b16bd83e6f2@googlegroups.com> <CAPTjJmp=PZPtNOpf06Oy-ZVH2CUQ0uUqwvJ0jU3+p8n8HsJ68g@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-173-75-251-66.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0
In-Reply-To <CAPTjJmp=PZPtNOpf06Oy-ZVH2CUQ0uUqwvJ0jU3+p8n8HsJ68g@mail.gmail.com>
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 <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.687.1358594886.2939.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1358594886 news.xs4all.nl 6939 [2001:888:2000:d::a6]:54834
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:37081

Show key headers only | View raw


On 1/19/2013 12:05 AM, Chris Angelico wrote:
> On Sat, Jan 19, 2013 at 3:50 PM, Cen Wang <iwarobots@gmail.com> wrote:
>> Hi, when I use multiprocessing.Process in this way:
>>
>> from multiprocessing import Process
>>
>> class MyProcess(Process):
>>
>>      def __init__(self):
>>          Process.__init__(self)
>>
>>      def run(self):
>>          print 'x'
>>
>> p = MyProcess()
>> p.start()
>>
>> It just keeps printing 'x' on my command prompt and does not end. But I think MyProcess should print an 'x' and then terminate. I don't why this is happening. I'm using Win7 64 bit, Python 2.7.3. Any idea? Thanks in advance.
>
> Multiprocessing on Windows requires that your module be importable. So
> it imports your main module, which instantiates another MyProcess,
> starts it, rinse and repeat. You'll need to protect your main routine
> code:
>
> if __name__=="__main__":
>      p = MyProcess()
>      p.start()

This is documented in
17.2.3. Programming guidelines
17.2.3.2. Windows

-- 
Terry Jan Reedy

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


Thread

Question related to multiprocessing.Process Cen Wang <iwarobots@gmail.com> - 2013-01-18 20:50 -0800
  Re: Question related to multiprocessing.Process Chris Angelico <rosuav@gmail.com> - 2013-01-19 16:05 +1100
    Re: Question related to multiprocessing.Process Cen Wang <iwarobots@gmail.com> - 2013-01-18 21:33 -0800
    Re: Question related to multiprocessing.Process Cen Wang <iwarobots@gmail.com> - 2013-01-18 21:33 -0800
  Re: Question related to multiprocessing.Process Terry Reedy <tjreedy@udel.edu> - 2013-01-19 06:27 -0500

csiph-web