Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37081
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: Question related to multiprocessing.Process |
| Date | 2013-01-19 06:27 -0500 |
| References | <6816f48f-753f-4ae3-be79-3b16bd83e6f2@googlegroups.com> <CAPTjJmp=PZPtNOpf06Oy-ZVH2CUQ0uUqwvJ0jU3+p8n8HsJ68g@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.687.1358594886.2939.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Find similar | Unroll 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