Skip to content

Commit 0fd5e88

Browse files
authored
Pass result or exception into update_memo (#4017)
This follows the Future API, which has two completion variants, one for success and one for exception, and #4006 which introduces that distinction in DFK task completion helpers. Right now, the two new update_memo variants do the same thing. However, an upcoming PR will move checkpoint code out of handle_app_update (which is race-prone - #3762) and into update_memo which runs before the result/exception is exposed to the user. That checkpoint code will then need to see the result/exception explicitly. # Changed Behaviour none ## Type of change - Code maintenance/cleanup
1 parent be81275 commit 0fd5e88

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

parsl/dataflow/dflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def _complete_task_result(self, task_record: TaskRecord, new_state: States, resu
539539
logger.info(f"Task {task_record['id']} completed ({old_state.name} -> {new_state.name})")
540540
task_record['time_returned'] = datetime.datetime.now()
541541

542-
self.memoizer.update_memo(task_record)
542+
self.memoizer.update_memo_result(task_record, result)
543543

544544
self._send_task_log_info(task_record)
545545

@@ -558,7 +558,7 @@ def _complete_task_exception(self, task_record: TaskRecord, new_state: States, e
558558
logger.info(f"Task {task_record['id']} failed ({old_state.name} -> {new_state.name})")
559559
task_record['time_returned'] = datetime.datetime.now()
560560

561-
self.memoizer.update_memo(task_record)
561+
self.memoizer.update_memo_exception(task_record, exception)
562562

563563
self._send_task_log_info(task_record)
564564

parsl/dataflow/memoization.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,13 @@ def check_memo(self, task: TaskRecord) -> Optional[Future[Any]]:
283283
assert isinstance(result, Future) or result is None
284284
return result
285285

286-
def update_memo(self, task: TaskRecord) -> None:
286+
def update_memo_result(self, task: TaskRecord, r: Any) -> None:
287+
self._update_memo(task)
288+
289+
def update_memo_exception(self, task: TaskRecord, e: BaseException) -> None:
290+
self._update_memo(task)
291+
292+
def _update_memo(self, task: TaskRecord) -> None:
287293
"""Updates the memoization lookup table with the result from a task.
288294
This doesn't move any values around but associates the memoization
289295
hashsum with the completed (by success or failure) AppFuture.

0 commit comments

Comments
 (0)