Davin Potts added the comment: It looks like the first 'Called Foo.__new__' is being reported by the child (pool of 1) process and the second 'Called Foo.__new__' is being reported by the parent process. In multiprocessing, because objects are by default serialized using pickle, this may be caused by the unpickling of the Foo object by the parent process which is something you would not experience when using ThreadPool because it does not have the same need for serialization.
Example showing invocation of __new__ as part of unpickling: >>> class Foo(object): ... def __new__(cls): ... print("New") ... return object.__new__(cls) ... >>> import pickle >>> f = Foo() New >>> pf = pickle.dumps(f, protocol=2) >>> pickle.loads(pf) # unpickling triggers __new__ New <__main__.Foo object at 0x1084a06d0> Having discovered this phenomenon, is this causing a problem for you somewhere in code? (Your example code on github was helpful, thank you, but it didn't merely demonstrated the behavior and didn't show where this was causing you pain.) ---------- nosy: +davin _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30018> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com