Feature: Cancel processes of cancelled futures#903
Conversation
for more information, see https://pre-commit.ci
…hub.com:pyiron/executorlib into refresh_memory_dict
for more information, see https://pre-commit.ci
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #903 +/- ##
=======================================
Coverage 93.61% 93.62%
=======================================
Files 38 38
Lines 1895 1897 +2
=======================================
+ Hits 1774 1776 +2
Misses 121 121 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/executorlib/task_scheduler/file/shared.py (1)
292-309:⚠️ Potential issue | 🟡 MinorCancelled task entries leak in
process_dict.After terminating cancelled processes, those keys are removed from
memory_dict(line 308 filters outdone()futures), but the corresponding entries remain inprocess_dict. This means:
- Stale references accumulate for the lifetime of the executor.
- On shutdown (line 102-107),
_cancel_processeswill attempt to re-terminate already-terminated processes.Consider cleaning up
process_dictalongsidememory_dict:Proposed fix
cancelled_lst = [ key for key, value in memory_dict.items() if value.done() and value.cancelled() ] _cancel_processes( process_dict={k: v for k, v in process_dict.items() if k in cancelled_lst}, terminate_function=terminate_function, pysqa_config_directory=pysqa_config_directory, backend=backend, ) + for key in cancelled_lst: + process_dict.pop(key, None) return {
🧹 Nitpick comments (1)
src/executorlib/task_scheduler/file/shared.py (1)
292-293: Nit:value.done()is redundant when combined withvalue.cancelled().For
concurrent.futures.Future,cancelled()impliesdone(). Thevalue.done()guard can be dropped without changing behavior.Proposed simplification
cancelled_lst = [ - key for key, value in memory_dict.items() if value.done() and value.cancelled() + key for key, value in memory_dict.items() if value.cancelled() ]
Summary by CodeRabbit