Skip to content

Conversation

tomMoral
Copy link
Contributor

@tomMoral tomMoral commented Aug 7, 2023

This PR ensures the errors raised by the iterator generating the task in joblib are raised in the user space thread and not in internal backend threads.

Fixes #1489

@codecov
Copy link

codecov bot commented Aug 7, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.07% ⚠️

Comparison is base (1756995) 94.94% compared to head (f353aad) 94.87%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1491      +/-   ##
==========================================
- Coverage   94.94%   94.87%   -0.07%     
==========================================
  Files          45       45              
  Lines        7492     7515      +23     
==========================================
+ Hits         7113     7130      +17     
- Misses        379      385       +6     
Files Changed Coverage Δ
joblib/parallel.py 96.95% <100.00%> (+0.03%) ⬆️
joblib/test/test_parallel.py 96.07% <100.00%> (-0.05%) ⬇️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

islice = list(itertools.islice(iterator, big_batch_size))
try:
islice = list(itertools.islice(iterator, big_batch_size))
except Exception as e:
Copy link
Contributor

@fcharras fcharras Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we try to catch KeyboardInterrupt ?

Maybe catch BaseException, but not StopIteration ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, not sure about how this would change the behavior here...

What happens on keyboard interrupt for now?
I am in favor of keeping this simple for this PR and we can improve this in a follow up PR if necessary?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am in favor of keeping this simple for this PR and we can improve this in a follow up PR if necessary?

Yes let's do that.

I thought KeyboardInterrupt will be caught by whatever thread is being executed at that time but I don't find clear explanation of that, it might only be the main thread. I don't recall hearing from issues with keyboardinterrupt being raised here anyway so my suggestion is probably off.

@fcharras
Copy link
Contributor

fcharras commented Aug 8, 2023

LGTM ?

tomMoral and others added 3 commits August 9, 2023 12:18
Co-authored-by: Franck Charras <29153872+fcharras@users.noreply.github.com>
Copy link
Contributor

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the fix!

@ogrisel ogrisel merged commit abd3af7 into joblib:master Aug 29, 2023
@tomMoral tomMoral deleted the FIX_raise_iterator_error branch April 8, 2024 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

joblib.Parallel silently fails to re-raise exception when n_jobs > 1 and n_iterations > n_jobs*2
3 participants