Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 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; 'subject:related': 0.09; 'terminate.': 0.09; 'way:': 0.09; 'def': 0.10; 'advance.': 0.15; 'sat,': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'instantiates': 0.16; 'run(self):': 0.16; 'win7': 0.16; 'wrote:': 0.17; 'module,': 0.17; 'jan': 0.18; 'windows': 0.19; 'module': 0.19; 'import': 0.21; 'skip:_ 20': 0.22; 'command': 0.24; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; '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; 'received:google.com': 0.34; 'thanks': 0.34; 'pm,': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'should': 0.36; 'skip:p 20': 0.36; 'keeps': 0.37; 'does': 0.37; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'think': 0.40; 'your': 0.60; "you'll": 0.62; 'protect': 0.69; 'prompt': 0.78; '2013': 0.84; 'repeat.': 0.84; 'rinse': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=fZwAV2QGD6pP3sy4RuT/4TVg6/xbZuQQaO2dQhUW3qI=; b=V6SJO6LegP0WqwxdWwgOycmTSzh+ucZyf9y9xG+QOli5l3yizRNDoeZBYfxim+JIk6 u2QYJj0WTlgxiQt5i4ICnRzzSIIExC+qK0RhZ/cFv/aSXZZHsul1RboPqZqJLln+FnMh tPQ4So3n7JDxbA8MYtFS7b1P5NeXw4JDOANlm/4NDMTIOqREBPmTnYzhRjRaq6QE/mSu dndJa0WQJM18XbP0b9ZsiA9q3um/tMYY5XB+NkfW4cXikgTio/N/Dq5GkCiPPiyfNigC QKBJipDQQfU7GtozfhzR9pP5KQQPJ7BNsCkWAa8B//7NHLoWYHKhWgJtYjnM+8ATTe4l WLew== MIME-Version: 1.0 X-Received: by 10.52.17.70 with SMTP id m6mr10781345vdd.92.1358571907820; Fri, 18 Jan 2013 21:05:07 -0800 (PST) In-Reply-To: <6816f48f-753f-4ae3-be79-3b16bd83e6f2@googlegroups.com> References: <6816f48f-753f-4ae3-be79-3b16bd83e6f2@googlegroups.com> Date: Sat, 19 Jan 2013 16:05:07 +1100 Subject: Re: Question related to multiprocessing.Process From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358571909 news.xs4all.nl 6895 [2001:888:2000:d::a6]:56723 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37050 On Sat, Jan 19, 2013 at 3:50 PM, Cen Wang 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() ChrisA