Skip to content

Commit

Permalink
Logging: show response time for heartbeats
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddyGuthridge committed Mar 30, 2024
1 parent dda8f4c commit 5b7a98b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion flapi/__comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,16 @@ def heartbeat() -> bool:
If no data is received, this function returns `False`.
"""
log.debug("heartbeat")
start = time.time()
try:
send_msg(consts.SYSEX_HEADER + bytes([
consts.MSG_FROM_CLIENT,
consts.MSG_TYPE_HEARTBEAT,
]))
response = receive_message()
assert_response_is_ok(response, consts.MSG_TYPE_HEARTBEAT)
log.debug("heartbeat: passed")
end = time.time()
log.debug(f"heartbeat: passed in {end - start:.3} seconds")
return True
except FlapiTimeoutError:
log.debug("heartbeat: failed")
Expand Down

0 comments on commit 5b7a98b

Please sign in to comment.