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


Groups > comp.lang.python > #37054

Re: Question related to multiprocessing.Process

Newsgroups comp.lang.python
Date 2013-01-18 21:33 -0800
References <6816f48f-753f-4ae3-be79-3b16bd83e6f2@googlegroups.com> <mailman.665.1358571909.2939.python-list@python.org>
Subject Re: Question related to multiprocessing.Process
From Cen Wang <iwarobots@gmail.com>
Message-ID <mailman.668.1358573617.2939.python-list@python.org> (permalink)

Show all headers | View raw


Thanks! It now works!
On Saturday, 19 January 2013 13:05:07 UTC+8, 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()
> 
> 
> 
> ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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