Skip to content

Commit

Permalink
Rename status name local variable (#205)
Browse files Browse the repository at this point in the history
This variable is set to be a UUID so include this in the name to be
explicit.
  • Loading branch information
joeshannon authored May 16, 2023
1 parent eb497fc commit aaccc3f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/blueapi/worker/reworker.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,25 +228,25 @@ def _waiting_hook(self, statuses: Optional[Iterable[Status]]) -> None:
self._monitor_status(status)

def _monitor_status(self, status: Status) -> None:
status_name = str(uuid.uuid4())
status_uuid = str(uuid.uuid4())

if isinstance(status, WatchableStatus) and not status.done:
LOGGER.info(f"Watching new status: {status_name}")
self._status_snapshot[status_name] = StatusView()
status.watch(partial(self._on_status_event, status, status_name))
LOGGER.info(f"Watching new status: {status_uuid}")
self._status_snapshot[status_uuid] = StatusView()
status.watch(partial(self._on_status_event, status, status_uuid))

# TODO: Maybe introduce an initial event, in which case move
# all of this code out of the if statement
def on_complete(status: Status) -> None:
self._on_status_event(status, status_name)
del self._status_snapshot[status_name]
self._on_status_event(status, status_uuid)
del self._status_snapshot[status_uuid]

status.add_callback(on_complete) # type: ignore

def _on_status_event(
self,
status: Status,
status_name: str,
status_uuid: str,
*,
name: Optional[str] = None,
current: Optional[float] = None,
Expand Down Expand Up @@ -274,7 +274,7 @@ def _on_status_event(
time_elapsed=time_elapsed,
time_remaining=time_remaining,
)
self._status_snapshot[status_name] = view
self._status_snapshot[status_uuid] = view
self._publish_status_snapshot()

def _publish_status_snapshot(self) -> None:
Expand Down

0 comments on commit aaccc3f

Please sign in to comment.