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 with multiprocessing #152

Open
Almenon opened this issue Nov 1, 2020 · 1 comment
Open

Error with multiprocessing #152

Almenon opened this issue Nov 1, 2020 · 1 comment
Labels

Comments

@Almenon
Copy link
Owner

Almenon commented Nov 1, 2020

AREPL version: 1.0.24

from multiprocessing import Pool
import os

processed=0

def f(x):
    global processed
    processed += 1
    print("Processed by %s: %s" % (os.getpid(), processed))
    return x

if __name__ == '__main__':
    pool = Pool(processes=1)
    print(pool.map(f, range(10)))
Traceback (most recent call last):
  line 14, in <module>
  File "C:\Users\almenon\AppData\Local\Programs\Python\Python36\lib\multiprocessing\pool.py", line 266, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "C:\Users\almenon\AppData\Local\Programs\Python\Python36\lib\multiprocessing\pool.py", line 644, in get
    raise self._value
  File "C:\Users\almenon\AppData\Local\Programs\Python\Python36\lib\multiprocessing\pool.py", line 424, in _handle_tasks
    put(task)
  File "C:\Users\almenon\AppData\Local\Programs\Python\Python36\lib\multiprocessing\connection.py", line 206, in send
    self._send_bytes(_ForkingPickler.dumps(obj))
  File "C:\Users\almenon\AppData\Local\Programs\Python\Python36\lib\multiprocessing\reduction.py", line 51, in dumps
    cls(buf, protocol).dump(obj)
_pickle.PicklingError: Can't pickle <function f at 0x00000203C03C4510>: attribute lookup f on __main__ failed

Print Output:
Variables:
-{
    pool: "AREPL could not pickle this object",
    processed: 0
}
39 ms
@Almenon
Copy link
Owner Author

Almenon commented Nov 1, 2020

Note that it works if you comment out the last line.

@Almenon Almenon added the bug label Nov 1, 2020
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

1 participant