mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Improve time change helper comments (#82349)
* Improve time change helper comments https://github.com/home-assistant/core/pull/82324#discussion_r1026962806 * Improve time change helper comments https://github.com/home-assistant/core/pull/82324#discussion_r1026962806
This commit is contained in:
parent
9fefa2e139
commit
e4666206ec
@ -385,10 +385,10 @@ def async_fire_time_changed_exact(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Fire a time changed event at an exact microsecond.
|
"""Fire a time changed event at an exact microsecond.
|
||||||
|
|
||||||
Consider that its not possible to actually achieve an exact microsecond
|
Consider that it is not possible to actually achieve an exact
|
||||||
in production as the event loop is not precise enough. If your code
|
microsecond in production as the event loop is not precise enough.
|
||||||
relies on this level of precision, consider a different approach
|
If your code relies on this level of precision, consider a different
|
||||||
as this is only for testing.
|
approach, as this is only for testing.
|
||||||
"""
|
"""
|
||||||
if datetime_ is None:
|
if datetime_ is None:
|
||||||
utc_datetime = date_util.utcnow()
|
utc_datetime = date_util.utcnow()
|
||||||
@ -404,10 +404,13 @@ def async_fire_time_changed(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Fire a time changed event.
|
"""Fire a time changed event.
|
||||||
|
|
||||||
This function will ensure microseconds at at least 500000
|
This function will add up to 0.5 seconds to the time to ensure that
|
||||||
to account for the synchronization repeating listeners.
|
it accounts for the accidental synchronization avoidance code in repeating
|
||||||
|
listeners.
|
||||||
|
|
||||||
If you need to fire an exact microsecond, use async_fire_time_changed_exact.
|
As asyncio is cooperative, we can't guarantee that the event loop will
|
||||||
|
run an event at the exact time we want. If you need to fire time changed
|
||||||
|
for an exact microsecond, use async_fire_time_changed_exact.
|
||||||
"""
|
"""
|
||||||
if datetime_ is None:
|
if datetime_ is None:
|
||||||
utc_datetime = date_util.utcnow()
|
utc_datetime = date_util.utcnow()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user