[issue19946] Have multiprocessing raise ImportError when spawning a process that can't find the "main" module

Olivier Grisel report at bugs.python.org
Wed Dec 11 09:41:19 CET 2013


Olivier Grisel added the comment:

> what is sys.modules['__main__'] and sys.modules['__main__'].__file__ if you run under nose?

$ cat check_stuff.py 
import sys

def test_main():
    print("sys.modules['__main__']=%r"
          % sys.modules['__main__'])
    print("sys.modules['__main__'].__file__=%r"
          % sys.modules['__main__'].__file__)


if __name__ == '__main__':
    test_main()
(pyhead) ogrisel at is146148:~/tmp$ python check_stuff.py 
sys.modules['__main__']=<module '__main__' from 'check_stuff.py'>
sys.modules['__main__'].__file__='check_stuff.py'
(pyhead) ogrisel at is146148:~/tmp$ nosetests -s check_stuff.py 
sys.modules['__main__']=<module '__main__' from '/volatile/ogrisel/envs/pyhead/bin/nosetests'>
sys.modules['__main__'].__file__='/volatile/ogrisel/envs/pyhead/bin/nosetests'
.
----------------------------------------------------------------------
Ran 1 test in 0.001s

OK

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19946>
_______________________________________


More information about the Python-bugs-list mailing list