def reduce_time_left(self, time_left):
        """
        Update the time left for generating events. This is typically
        used by event generators that currently don't want to generate
        an event but know that they will within a certain time. By
        reducing the time left, they make sure that they are reinvoked
        when the time for generating the event has come (at the latest).

        This method can only be used to reduce the time left. If the
        parameter is larger than the current value of time left, it is
        ignored.

        If the time left is reduced to 0 and the event is currently
        being handled, the handler's *resume* method is invoked.
        """

        with self._lock:
            if time_left >= 0 and (self._time_left < 0
                                   or self._time_left > time_left):
                self._time_left = time_left
                if self._time_left == 0 and self.handler is not None:
                    m = getattr(
                        getattr(
                            self.handler, "im_self", getattr(
                                self.handler, "__self__"
                            )
                        ),
                        "resume", None
                    )
                    if m is not None and ismethod(m):
                        m()
dataset/ETHPy150Open circuits/circuits/circuits/core/events.py/generate_events.reduce_time_left/original