Avoid calling time.monotonic on coordinator refresh unless we are debugging (#70209)

This commit is contained in:
J. Nick Koston 2022-04-17 19:40:44 -10:00 committed by GitHub
parent 80ab8b465b
commit c393622b64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -183,6 +183,7 @@ class DataUpdateCoordinator(Generic[_T]):
if scheduled and self.hass.is_stopping:
return
if log_timing := self.logger.isEnabledFor(logging.DEBUG):
start = monotonic()
auth_failed = False
@ -255,6 +256,7 @@ class DataUpdateCoordinator(Generic[_T]):
self.logger.info("Fetching %s data recovered", self.name)
finally:
if log_timing:
self.logger.debug(
"Finished fetching %s data in %.3f seconds (success: %s)",
self.name,