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

Pool's map, imap, apply, apply_async, etc fail on Windows #6

Closed
mmckerns opened this issue Jun 26, 2015 · 3 comments
Closed

Pool's map, imap, apply, apply_async, etc fail on Windows #6

mmckerns opened this issue Jun 26, 2015 · 3 comments

Comments

@mmckerns
Copy link
Member

>>> import multiprocess as mp
>>> import time
>>> 
>>> def sleepy_squared(x):
…     time.sleep(0.2)
…     return x**2
…
>>> mp.Pool().map(sleepy_squared, range(2))

On Windows, this fails with a NameError -- global name time not defined.

However, it can be avoided by using:
dill.settings['trace'] = True
Results then are as expected.

@mmckerns
Copy link
Member Author

There appear to be other similar (yet different) test failures when dill.settings['recurse'] = True has been set as the dill default -- even on a rebuild of dill and multiprocess.

It looks like the best workaround for the time being is to include the import inside the function whenever possible.

>>> import multiprocess as mp
>>> 
>>> def sleepy_squared(x):
…     import time
…     time.sleep(0.2)
…     return x**2
…
>>> mp.Pool().map(sleepy_squared, range(2))
[0, 1]

@mmckerns
Copy link
Member Author

Note that this works as originally expected on non-windows systems.

Python 2.7.9 (default, Dec 11 2014, 01:21:43) 
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocess as mp
>>> import time
>>> 
>>> def sleepy_squared(x):
...   time.sleep(0.2)
...   return x**2
... 
>>> mp.Pool().map(sleepy_squared, range(2))
[0, 1]
>>> 
>>> import dill
>>> dill.settings['trace'] = True
>>> 
>>> mp.Pool().map(sleepy_squared, range(2))
[0, 1]

@mmckerns
Copy link
Member Author

mmckerns commented May 5, 2020

closed due to uqfoundation/dill#363

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