Lewis Gaul <[email protected]> added the comment:
Just to move the conversation from the subinterpreters project repo to here...
I'm going to take a look at how this is done by subprocess using the example
provided by Guido:
import os
from concurrent.futures import ProcessPoolExecutor
from multiprocessing import get_context
class C:
def __getstate__(self):
print("pickled in %d" % os.getpid())
return {}
def __setstate__(self, state):
print("unpickled in %d" % os.getpid())
def hello(self):
print("Hello world")
if __name__ == "__main__":
with ProcessPoolExecutor(mp_context=get_context("spawn")) as ex:
ex.submit(C().hello).result()
Output:
pickled in 23480
unpickled in 23485
Hello world
----------
nosy: +LewisGaul
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37292>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com