Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename status name local variable #205

Merged
merged 1 commit into from
May 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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