classification
Title: multiprocessing.Process child process imports package instead of parent file
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: hct, r.david.murray
Priority: normal Keywords:

Created on 2013-05-01 01:28 by hct, last changed 2013-05-01 01:38 by r.david.murray. This issue is now closed.

Messages (2)
msg188197 - (view) Author: HCT (hct) Date: 2013-05-01 01:28
created a project with the following content
CODEC/
CODEC/video.py
CODEC/audio.py
CODEC/__init__.py
CRC/
CRC/crc24.py
CRC/crc32.py
CRC/__init__.py
TEST/test_crc.py
TEST/test_codec.py
TEST/__init__.py
__init__.py
test.py
main.py


test.py contain tests that launches multiple multiprocessing.Process to test diffferent module in parallel, but always fail to launch child processes for test with AttributeError. I spent lots of time trying to figure out why my code don't work. I also tried to use the examples from http://docs.python.org/dev/library/multiprocessing.html#the-process-class and they also gives AttributeError when launching child process. in the end, I figured out it's because Pythong file test.py has same name as package TEST. change test.py to test_all.py and everything worked.

It looks multiprocessing import defaults to import package, not the parent file when file name without suffix is same as package.
msg188198 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-05-01 01:38
I take it you are on a case insensitive file system, in which case this is just the way imports work in Python: a package is preferred to a .py file with the same name.
History
Date User Action Args
2013-05-01 01:38:09r.david.murraysetstatus: open -> closed

type: compile error ->

nosy: + r.david.murray
messages: + msg188198
resolution: not a bug
stage: resolved
2013-05-01 01:28:02hctcreate