Skip to content
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

Error using multiprocessing with pyconcrete #98

Open
sharadkak opened this issue Jul 7, 2022 · 0 comments
Open

Error using multiprocessing with pyconcrete #98

sharadkak opened this issue Jul 7, 2022 · 0 comments
Labels

Comments

@sharadkak
Copy link

sharadkak commented Jul 7, 2022

Hi,

I'm getting a pickle error while using multiprocessing with Pyconcrete. However the code works just fine without pyconcrete.
I am using python 3.8 with docker. To create a docker image I am using the docker file from the repository https://github.com/Falldog/pyconcrete/blob/master/docker/Dockerfile.

The error I am getting is
Traceback (most recent call last): File "main.py", line 17, in <module> File "/usr/lib/python3.8/multiprocessing/process.py", line 121, in start self._popen = self._Popen(self) File "/usr/lib/python3.8/multiprocessing/context.py", line 284, in _Popen return Popen(process_obj) File "/usr/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 32, in __init__ super().__init__(process_obj) File "/usr/lib/python3.8/multiprocessing/popen_fork.py", line 19, in __init__ self._launch(process_obj) File "/usr/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 47, in _launch reduction.dump(process_obj, fp) File "/usr/lib/python3.8/multiprocessing/reduction.py", line 60, in dump ForkingPickler(file, protocol).dump(obj) _pickle.PicklingError: Can't pickle <function task_fn at 0x7f376688b1f0>: attribute lookup task_fn on __main__ failed

I also attach the code below:

import os
import time

def task_fn(l):
    results = []
    for each in l:
        print(each**20)

if __name__ == '__main__':
    print("Main process id ", os.getpid())
    l = [i**2 for i in range(10)]

    ctx = mp.get_context('spawn')
    p = ctx.Process(target= task_fn, args = (l,))
    p.start()
    print(p.name)
    p.join()
    p.close()
@Falldog Falldog added the bug label Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants