This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Multiprocessing fails when using functions defined in interactive interpreter.
Type: behavior Stage: resolved
Components: Interpreter Core, Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ppperry, r.david.murray
Priority: normal Keywords:

Created on 2015-04-19 17:21 by ppperry, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg241521 - (view) Author: (ppperry) Date: 2015-04-19 17:21
An AttributeError is raised when starting a new process with an object defined in the interactive interpreter
>>>def test():print "test"
>>>test()
test
>>>from threading import Thread
>>>Thread(target=test).start()
test
>>>from multiprocessing import Process
>>>Process(target=test).start()
<traceback, ending with>
File <path to python>/Lib/pickle.py, line 1126, in find_class
      klass = getattr(mod, name)
AttributeError: 'module' object has no attribute 'test'
running similar code in a file works and does not raise an error.
msg241545 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-04-19 19:13
I'm guessing you are on Windows.  Please read https://docs.python.org/2/library/multiprocessing.html#windows.  You can't do what you show on windows (though you can on unix, since it uses fork).
History
Date User Action Args
2022-04-11 14:58:15adminsetgithub: 68194
2015-04-19 19:13:08r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg241545

resolution: not a bug
stage: resolved
2015-04-19 17:21:01ppperrycreate