This commit is contained in:
Christian Mantha
2026-03-02 19:10:52 -05:00
commit 2ca0b9ef7c
28907 changed files with 5233713 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
import abc
import time
class Clock(metaclass=abc.ABCMeta):
@abc.abstractmethod
def time(self) -> float:
"""
Return the current time in seconds since the Epoch.
Fractions of a second may be present if the system clock provides them.
:return: The current time in seconds since the Epoch.
"""
@abc.abstractmethod
def sleep(self, seconds: float) -> None:
"""
Delay execution for a given number of seconds. The argument may be
a floating point number for subsecond precision.
:param seconds: The duration to sleep in seconds.
:return:
"""
class RealClock(Clock):
"""
A real clock that uses the ``time`` module to get the current time and sleep.
"""
def time(self) -> float:
"""
Return the current time in seconds since the Epoch.
Fractions of a second may be present if the system clock provides them.
:return: The current time in seconds since the Epoch.
"""
return time.time()
def sleep(self, seconds: float) -> None:
"""
Delay execution for a given number of seconds. The argument may be
a floating point number for subsecond precision.
:param seconds: The duration to sleep in seconds.
:return:
"""
time.sleep(seconds)