-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_pickle.PicklingError
on 3.14.0a1+ where it didn't before due to the start method change from fork to forkserver
#125714
Comments
Your repro case also fails for me on 3.11 through 3.13. Simpler code that fails similarly: import pickle
class X: pass
s = super(X, X())
pickle.dumps(s) |
Strange, my repro case Yours does fail on 3.11.2 too, though. |
Can you try this? import multiprocessing
def f():
def g():
print("hello")
multiprocessing.Process(target=g).start()
if __name__ == "__main__":
f() For me it passes on 3.11.2, but fails on |
Oh, this is because I am on MacOS. The relevant change is listed in https://docs.python.org/3.14/whatsnew/3.14.html#deprecated: the default start method moved from fork to forkserver on Linux. With fork, I guess we didn't need things to be picklable. cc @gpshead as the author of this change, but I think this will be a won't fix: We made that change after careful consideration, and this sort of issue was a known consequence. If you want the old behavior, you can either explicitly use the fork start method or refactor your code so the relevant objects can be pickled. There might be room for improvements in how |
Ah, I understand. Thanks! I feel there is some room for improvement regarding documentation here, as this is a breaking change and not a deprecation as far as I can tell. And neither the changelog nor "Contexts and start methods" mentions only |
Agreed, this is mostly a documentation issue. But I don't have a good feel for exactly what to state. Care to draft up some text in a PR @progval? I think we'd want this to be clarified in both what's new 3.14 and multiprocessing docs. |
Done in #125750 |
@progval If you're interested, feel free to open an issue specifically about pickling
|
Created a separate issue for pickling |
Given the user reports (now plural) on this one, we should also catch and improve the error message within multiprocessing when pickle fails to at least point people in the right direction. |
_pickle.PicklingError
on 3.14.0a1+ when starting a process that references its super()
_pickle.PicklingError
on 3.14.0a1+ where it didn't before due to the start method change from fork to forkserver
Bug report
Bug description:
Code dating back to Python 2 had to do
super(OwnClassName, self)
instead ofsuper()
. Modules designed to be reloadable could not use thesuper(OwnClassName, self)
syntax in their non-constructor method, asOwnClassName
was re-binded to the class of the new module, rather than the class that had the name when the object was constructed (which differs when the object was constructed before a reload). Therefore, such modules defined classes like this:Python 3.14.0a1+ breaks existing code using this trick on subclasses of
multiprocessing.Process
.For example:
worked fine on previous versions, but now errors with:
Full version string:
Python 3.14.0a1+ (heads/main:c8fd4b12e3d, Oct 18 2024, 22:51:39) [GCC 12.2.0] on linux
CPython versions tested on:
3.14, CPython main branch
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: