Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/simulator/origins.py
Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | |||||
) -> Iterator[Event]: | ) -> Iterator[Event]: | ||||
"""A loading task. This pushes OriginVisitStatus objects to the | """A loading task. This pushes OriginVisitStatus objects to the | ||||
status_queue to simulate the visible outcomes of the task. | status_queue to simulate the visible outcomes of the task. | ||||
Uses the `load_task_duration` function to determine its run time. | Uses the `load_task_duration` function to determine its run time. | ||||
""" | """ | ||||
# This is cheating; actual tasks access the state from the storage, not the | # This is cheating; actual tasks access the state from the storage, not the | ||||
# scheduler | # scheduler | ||||
stats = env.scheduler.origin_visit_stats_get(task.origin, task.visit_type) | pk = task.origin, task.visit_type | ||||
visit_stats = env.scheduler.origin_visit_stats_get([pk]) | |||||
stats: Optional[OriginVisitStats] = visit_stats[0] if len(visit_stats) > 0 else None | |||||
last_snapshot = stats.last_snapshot if stats else None | last_snapshot = stats.last_snapshot if stats else None | ||||
status = OriginVisitStatus( | status = OriginVisitStatus( | ||||
origin=task.origin, | origin=task.origin, | ||||
visit=42, | visit=42, | ||||
type=task.visit_type, | type=task.visit_type, | ||||
status="created", | status="created", | ||||
date=env.time, | date=env.time, | ||||
Show All 23 Lines |