Skip to content

Commit

Permalink
Rename delay_time to send_time
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly committed Sep 9, 2024
1 parent 2e39c04 commit fba2c6f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions bellows/ezsp/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,28 @@ def _get_command_priority(self, name: str) -> int:

async def command(self, name, *args, **kwargs) -> Any:
"""Serialize command and send it."""
delay_time = 0
was_delayed = False
delayed = False
send_time = None

if self._send_semaphore.locked():
delayed = True
send_time = time.monotonic()

Check warning on line 98 in bellows/ezsp/protocol.py

View check run for this annotation

Codecov / codecov/patch

bellows/ezsp/protocol.py#L97-L98

Added lines #L97 - L98 were not covered by tests

LOGGER.debug(

Check warning on line 100 in bellows/ezsp/protocol.py

View check run for this annotation

Codecov / codecov/patch

bellows/ezsp/protocol.py#L100

Added line #L100 was not covered by tests
"Send semaphore is locked, delaying before sending %s(%r, %r)",
name,
args,
kwargs,
)
delay_time = time.monotonic()
was_delayed = True

async with self._send_semaphore(priority=self._get_command_priority(name)):
if was_delayed:
if delayed:
LOGGER.debug(

Check warning on line 109 in bellows/ezsp/protocol.py

View check run for this annotation

Codecov / codecov/patch

bellows/ezsp/protocol.py#L109

Added line #L109 was not covered by tests
"Sending command %s: %s %s after %0.2fs delay",
name,
args,
kwargs,
time.monotonic() - delay_time,
time.monotonic() - send_time,
)
else:
LOGGER.debug("Sending command %s: %s %s", name, args, kwargs)
Expand Down

0 comments on commit fba2c6f

Please sign in to comment.