New submission from cyberlis <cyber...@rccraft.ru>:
When I use python3.7 everything works correctly and every subprocess has its own `Hello` instance. When I use python3.8 subprocesses do not have an instance of `Hello` class. Is this behavior correct? My code to reproduce an issue ```python from concurrent.futures.process import ProcessPoolExecutor from concurrent.futures import as_completed class Hello: _instance = None def __init__(self): print("Creating instance of Hello ", self) Hello._instance = self def worker(): return Hello._instance def main(): hello = Hello() with ProcessPoolExecutor(max_workers=2) as pool: futures = [] for _ in range(4): futures.append(pool.submit(worker)) for future in as_completed(futures): print(future.result()) if __name__ == "__main__": main() ``` Output ```bash pyenv local 3.7.6 python main.py Creating instance of Hello <__main__.Hello object at 0x102f48310> <__main__.Hello object at 0x103587410> <__main__.Hello object at 0x1035874d0> <__main__.Hello object at 0x103587110> <__main__.Hello object at 0x1035871d0> pyenv local 3.8.1 python main.py Creating instance of Hello <__main__.Hello object at 0x102104d90> None None None None ``` ---------- files: main.py messages: 371117 nosy: cyberlis priority: normal severity: normal status: open title: Multiprocessing. Instance of the custom class is missing in subprocesses type: behavior versions: Python 3.8 Added file: https://bugs.python.org/file49223/main.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40929> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com