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.

Author terry.reedy
Recipients cool-RR, ezio.melotti, jnoller, petri.lehtinen, r.david.murray, terry.reedy
Date 2011-05-27.17:57:19
SpamBayes Score 1.5415199e-09
Marked as misclassified No
Message-id <1306519040.76.0.658254788508.issue11969@psf.upfronthosting.co.za>
In-reply-to
Content
After looking at the doc chapter, I get that 'if __name__' block is needed on Windows.

OK. batch mode with if __name__ block:

testmp.py
---------
print('Top of Module')
class C:
    def f(s): print('Method C.f')

if __name__ == '__main__':
    print('Start of main block')
    import multiprocessing
    p = multiprocessing.Process(target=C.f, args=(C(),))
    p.start()
    p.join()

command-prompt..\python32> python @misc2\testmp.py

output (similar to that of OP):

Top of Module
Start of main block
Traceback (most recent call last):
  File "C:\Programs\Python32\lib\pickle.py", line 679, in save_global
    klass = getattr(mod, name)
AttributeError: 'module' object has no attribute 'f'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "@misc2\testmp.py", line 9, in <module>
    p.start()
  File "C:\Programs\Python32\lib\multiprocessing\process.py", line 130, in start

    self._popen = Popen(self)
  File "C:\Programs\Python32\lib\multiprocessing\forking.py", line 267, in __init__
    dump(process_obj, to_child, HIGHEST_PROTOCOL)
  File "C:\Programs\Python32\lib\multiprocessing\forking.py", line 190, in dump
    ForkingPickler(file, protocol).dump(obj)
  File "C:\Programs\Python32\lib\pickle.py", line 237, in dump
    self.save(obj)
  File "C:\Programs\Python32\lib\pickle.py", line 344, in save
    self.save_reduce(obj=obj, *rv)
  File "C:\Programs\Python32\lib\pickle.py", line 432, in save_reduce
    save(state)
  File "C:\Programs\Python32\lib\pickle.py", line 299, in save
    f(self, obj) # Call unbound method with explicit self
  File "C:\Programs\Python32\lib\pickle.py", line 623, in save_dict
    self._batch_setitems(obj.items())
  File "C:\Programs\Python32\lib\pickle.py", line 656, in batch_setitems
    save(v)
  File "C:\Programs\Python32\lib\pickle.py", line 299, in save
    f(self, obj) # Call unbound method with explicit self
  File "C:\Programs\Python32\lib\pickle.py", line 683, in save_global
    (obj, module, name))
_pickle.PicklingError: Can't pickle <function f at 0x00B4B4B0>: it's not found as __main__.f

C:\Programs\Python32>Top of Module
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Programs\Python32\lib\multiprocessing\forking.py", line 370, in main
    self = load(from_parent)
EOFError

The essential problem seems to be the attempt to pickle the method attribute of the class as a class attribute of the module.
History
Date User Action Args
2011-05-27 17:57:21terry.reedysetrecipients: + terry.reedy, jnoller, ezio.melotti, r.david.murray, cool-RR, petri.lehtinen
2011-05-27 17:57:20terry.reedysetmessageid: <1306519040.76.0.658254788508.issue11969@psf.upfronthosting.co.za>
2011-05-27 17:57:20terry.reedylinkissue11969 messages
2011-05-27 17:57:19terry.reedycreate