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

Timeout handlers "timeout" when certain objects are returned #886

Closed
cicdw opened this issue Apr 3, 2019 · 2 comments · Fixed by #907
Closed

Timeout handlers "timeout" when certain objects are returned #886

cicdw opened this issue Apr 3, 2019 · 2 comments · Fixed by #907
Labels
bug Something isn't working

Comments

@cicdw
Copy link
Member

cicdw commented Apr 3, 2019

The timeout handlers in prefect.utilities.executors generally work well. However, I've stumbled across an edge case in which they incorrectly signify a timeout occurred, when clearly one didn't occur:

import prefect
from prefect.utilities.executors import multiprocessing_timeout

multiprocessing_timeout(lambda: prefect.context, timeout=2)
# >> TimeoutError: Execution timed out.

The timeout handlers work by placing objects into Queues, so for some reason it seems that certain objects disappear from the Queue.

This is almost certainly related to the fact that context is thread.local as seen by the following example:

import prefect
from prefect.utilities.executors import multiprocessing_timeout

multiprocessing_timeout(lambda: prefect.context.to_dict(), timeout=2)
# returns a dictionary

I think returning objects from context is a reasonable enough thing that we should either find a way to detect this or raise a more informative error.

@cicdw cicdw added the bug Something isn't working label Apr 3, 2019
@cicdw
Copy link
Member Author

cicdw commented Apr 3, 2019

In addressing this, we should also add tests to ensure the logger survives the timeout handling process (#887)

@cicdw cicdw mentioned this issue Apr 3, 2019
3 tasks
@cicdw
Copy link
Member Author

cicdw commented Apr 5, 2019

For the multiprocessing timeout handler, this might be unavoidable. The best we could do is use multiprocess instead of multiprocessing, which uses the dill serializer instead of pickle, but either way prefect.context isn't handled well. It appears that customizing the serializer isn't really an exposed option right now, otherwise we could use cloudpickle. :/

@cicdw cicdw mentioned this issue Apr 5, 2019
3 tasks
@cicdw cicdw closed this as completed in #907 Apr 5, 2019
abrookins pushed a commit that referenced this issue Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant