In a file called test.py
I have
print 'i am cow'
import multi4
print 'i am cowboy'
and in multi4.py
I have
import multiprocessing as mp
manager = mp.Manager()
print manager
I am confused by the way this code operates.
At the command line, if I type python
and then in the python environment if I type import test.py
I get the expected behavior:
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
>>>import test
i am cow
<multiprocessing.managers.SyncManager object at 0x025209B0>
i am cowboy
>>>
However if I type test.py
at the command line, I get
i am cow
i am cow
i am cow
i am cow
i am cow
i am cow
i am cow
i am cow
i am cow
i am cow
i am cow
i am cow
i am cow
i am cow
i am cow
i am cow
i am cow
i am cow
Which would presumably go on forever unless I kill it. When I kill it, I get a bunch of repeated errors:
KeyboardInterrupt
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python27\lib\multiprocessing\forking.py", line 373, in main
prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 488, in prepare
'__parents_main__', file, path_name, etc
KeyboardInterrupt
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python27\lib\multiprocessing\forking.py", line 373, in main
prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 488, in prepare
'__parents_main__', file, path_name, etc
KeyboardInterrupt
So what is going on? Why does it behave one way under import, and another when I try to run it?