Repository navigation
Fix scheduler thread dying on unpicklable submit arguments #1062
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
Merged
jan-janssen
merged 12 commits into
main
from
fix/1057-unpicklable-submit-hangs-scheduler
Sep 10, 2026
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9ad8acd
Fix scheduler thread dying on unpicklable submit arguments (#1057)
jan-janssen 1d23164
Format black
pyiron-runner 13e6a10
minimal changes
jan-janssen c3fc8e4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b047b80
Merge branch 'main' into fix/1057-unpicklable-submit-hangs-scheduler
jan-janssen 6ec23d3
mypy fixes
jan-janssen fccdd6b
be more explicit
jan-janssen 5c44704
handle error when cache key is set
jan-janssen 0952489
Add cache-key unpicklable test coverage
Copilot 889edf9
add exception
jan-janssen bdf2398
ignore too many statements
jan-janssen 185fdbd
Add file backend cache-key unpicklable tests
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Unpicklable arguments stay undetected when
cache_keyis set.serialize_functonly callscloudpickle.dumpswhen it must generate a task key, so an explicitcache_keybypasses the new failure detection. Both schedulers then serialize the raw objects later, on the scheduler thread, and the original thread-death defect remains.src/executorlib/standalone/serialize.py#L72-L81: move thecloudpickle.dumpsattempt outside thecache_keybranch so the third return value reports the failure for every key source.src/executorlib/task_scheduler/interactive/shared.py#L152-L152: wrapsend_and_receive_dictand the followingdump()call in the same try/except used by_execute_task_without_cache, and set the exception onfuture_obj.src/executorlib/task_scheduler/file/shared.py#L132-L138: after the fix inserialize_funct, confirm that acache_keytask with unpicklable arguments reaches theserialize_exceptionbranch instead ofexecute_function.📍 Affects 3 files
src/executorlib/standalone/serialize.py#L72-L81(this comment)src/executorlib/task_scheduler/interactive/shared.py#L152-L152src/executorlib/task_scheduler/file/shared.py#L132-L138🤖 Prompt for AI Agents
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.
I can confirm this one. With a user-supplied
cache_keythe hang from #1057 is still present at fccdd6b, because the guardedcloudpickle.dumpsinserialize_functis only reached when the key has to be generated.Checked with an
ase.Atomscarrying apyace.PyACECalculator(the original trigger) and with the minimal class below, same result in each case:SingleNodeExecutor(cache_directory=...), per-taskresource_dict={"cache_key": ...}shutdown()hangsSingleNodeExecutor(block_allocation=True, cache_directory=..., resource_dict={"cache_key": ...})FileTaskScheduler, per-taskcache_keySingleNodeExecutor(block_allocation=True, cache_directory=...), per-taskcache_keyonlyresource_dictentries, so no key is appliedEscape points from the thread tracebacks:
_execute_task_with_cache->interface.send_and_receive_dict->send_dict->cloudpickle.dumps(thetry/exceptwas only added to_execute_task_without_cache)execute_tasks_h5->subprocess_execute->hdf.dump->cloudpickle.dumpsReproducer (no external deps):
Two ways to close it:
Minimal: always attempt
cloudpickle.dumpsinserialize_funct(only skip the hashing whencache_keyis given), and wrapsend_and_receive_dictplus thedump()in_execute_task_with_cachein the sametry/exceptas the no-cache path. Small diff, but the arguments still get pickled twice on the happy path (once for the check, once in the socket / hdf layer), and a failure only shows up onresult().Serialize once, early: pickle
fn/args/kwargsa single time as early as possible, ideally insubmit()before the task reaches the queue, and thread the bytes through tosend_dict/hdf.dumpinstead of re-pickling the objects there. That covers every key source and every backend in one place, removes the double pickling, and also gives the fail-fast-at-submit()behaviour asked for in [Bug] Unpicklable submit argument kills the scheduler thread and hangs all futures forever #1057. It is a bigger change because the socket and hdf layers currently take the objects, not the bytes, and dependency resolution ofFuturearguments happens on the scheduler thread, so the "early" point may have to be the top of the scheduler loop rather thansubmit()itself.I would lean towards 2 if you think it is feasible, but that is your call, @jan-janssen. Option 1 would be fine to unblock this PR.