import time

from timeutil import Sleeper
from ._ClockStub import ClockStub


class NoSleeper(Sleeper):
    def __init__(self, clock_to_update: ClockStub = None):
        self.clock_to_update = clock_to_update

    def sleep(self, secs):
        if self.clock_to_update is not None and hasattr(self.clock_to_update, "sleep_for"):
            self.clock_to_update.sleep_for(seconds=secs)
        time.sleep(0)
