Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17700 > unrolled thread
| Started by | Andrew Berg <bahamutzero8825@gmail.com> |
|---|---|
| First post | 2011-12-21 14:11 -0600 |
| Last post | 2011-12-22 12:17 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Why does this launch an infinite loop of new processes? Andrew Berg <bahamutzero8825@gmail.com> - 2011-12-21 14:11 -0600
Re: Why does this launch an infinite loop of new processes? Hans Mulder <hansmu@xs4all.nl> - 2011-12-22 12:17 +0100
| From | Andrew Berg <bahamutzero8825@gmail.com> |
|---|---|
| Date | 2011-12-21 14:11 -0600 |
| Subject | Re: Why does this launch an infinite loop of new processes? |
| Message-ID | <mailman.3958.1324498271.27778.python-list@python.org> |
On 12/21/2011 1:29 PM, Ethan Furman wrote: > Anything that runs at import time should be protected by the `if > __name__ == '__main__'` idiom as the children will import the __main__ > module. So the child imports the parent and runs the spawn code again? That makes sense. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 | Thunderbird 7.0
[toc] | [next] | [standalone]
| From | Hans Mulder <hansmu@xs4all.nl> |
|---|---|
| Date | 2011-12-22 12:17 +0100 |
| Message-ID | <4ef311bd$0$6870$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #17700 |
On 21/12/11 21:11:03, Andrew Berg wrote: > On 12/21/2011 1:29 PM, Ethan Furman wrote: >> Anything that runs at import time should be protected by the `if >> __name__ == '__main__'` idiom as the children will import the __main__ >> module. > So the child imports the parent and runs the spawn code again? That > makes sense. It's platform dependent. On Windows, the child imports the parent and you get the phenomenon your ran into. On Posix platforms, multiprocessing uses fork(), and your code runs without problems. It would still be a good idea to use the `if __name__ is '__main__'` idiom, even on Posix platforms. Hope this helps, -- HansM
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web