예제 #1
0
def _do_mark_result_unchanged(
    workflow_id: int, step: Step, now: datetime.datetime
) -> None:
    """Do database manipulations for mark_result_unchanged().

    Modify `step` in-place.

    Raise Step.DoesNotExist or Workflow.DoesNotExist in case of a race.
    """
    with _locked_step(workflow_id, step):
        step.is_busy = False
        step.last_update_check = now
        step.save(update_fields=["is_busy", "last_update_check"])
예제 #2
0
def _do_create_result(
    workflow_id: int, step: Step, result: FetchResult, now: datetime.datetime
) -> None:
    """Do database manipulations for create_result().

    Modify `step` in-place.

    Do *not* do the logic in SetStepDataVersion. We're creating a new
    version, not doing something undoable.

    Raise Step.DoesNotExist or Workflow.DoesNotExist in case of a race.
    """
    with _locked_step(workflow_id, step):
        storedobjects.create_stored_object(
            workflow_id, step.id, result.path, stored_at=now
        )
        storedobjects.delete_old_files_to_enforce_storage_limits(step=step)
        # Assume caller sends new list to clients via SetStepDataVersion

        step.fetch_errors = result.errors
        step.is_busy = False
        step.last_update_check = now
        step.save(update_fields=["fetch_errors", "is_busy", "last_update_check"])