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
Fix multiprocessing timeout #3511
Conversation
This was breaking because the locally defined helper function was not serializable by the Python pickler. This change also serializes the given function using `cloudpickle` to fix passing tasks that are defined in a script rather than a module.
Previously process scheduled execution timeouts were untested
Previously was using the threaded scheduler perhaps because a default option changed in the past
For testing timeouts in processes
The only way I can figure out to make this bool visible to tests
Asserts - The warning was given for daemon executors - "invalid" is not written except for daemon executors Additionally bumps the sleep by a second because tests were failing locally for me, moves the sleep into a variable because it's used twice and if not changed in both locations the test will be invalid
The referenced pickling error does not appear to occur on Linux just OSX 🤷 |
Nice find, I'll give this a longer review after lunch.
In python 3.8 osx switched to using spawn by default, while linux still uses fork (where pickling won't be needed). |
Allows us to skip setting an attribute Co-authored-by: Jim Crist-Harif <jcrist@users.noreply.github.com>
Was failing locally with no file written yet
Otherwise 'invalid' was not being consistently written to the file which would give false-passes for this test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One final tweak and this looks good to me.
Using a payload arg to serialize all the inputs
To be consistent with passed callables elsewhere
Summary
The value retrieval in the
multiprocessing_timeout
was using a locally defined helper functionwhich could not be serialized by the native Python pickler resulting in an error running tasks with
a timeout while using a process based scheduler.
Example
Results in the error
AttributeError: Can't pickle local object 'multiprocessing_timeout.<locals>.retrieve_value'
Also fixes a timeout issue with function pickling similar to #2634
Changes
multiprocessing_timeout.retrieve_value
function to a top-level functionretrieve_value
tomultiprocessing_safe_retrieve_value
multiprocessing_safe_retrieve_value
takes a cloudpickle serialized callable so tasks defined in scripts can be passedmproc
andmproc_local
executors to the flow timeout testmultiprocessing_timeout
function__processes
attribute to distributed test executorsImportance
Checklist
This PR:
changes/
directory (if appropriate)docs/outline.toml
for API reference docs (if appropriate)