def METHOD_NAME(self, stdin, callbacks):
    if self.closed:
        raise Exception('Event loop already closed.')
    current_timeout = INPUT_TIMEOUT_MS
    self._running = True
    while self._running:
        # Call inputhook.
        with TimeIt() as inputhook_timer:
            if self._inputhook_context:
                def ready(wait):
                    " True when there is input ready. The inputhook should return control. "
                    return bool(self._ready_for_reading(current_timeout if wait else 0))
                self._inputhook_context.call_inputhook(ready)
        # Calculate remaining timeout. (The inputhook consumed some of the time.)
        if current_timeout == -1:
            remaining_timeout = -1
        else:
            remaining_timeout = max(0, current_timeout - int(1000 * inputhook_timer.duration))
        # Wait for the next event.
        handle = self._ready_for_reading(remaining_timeout)
        if handle == self._console_input_reader.handle.value:
            # When stdin is ready, read input and reset timeout timer.
            keys = self._console_input_reader.read()
            for k in keys:
                callbacks.feed_key(k)
            current_timeout = INPUT_TIMEOUT_MS
        elif handle == self._event.value:
            # When the Windows Event has been trigger, process the messages in the queue.
            windll.kernel32.ResetEvent(self._event)
            self._process_queued_calls_from_executor()
        elif handle in self._read_fds:
            callback = self._read_fds[handle]
            callback()
        else:
            # Fire input timeout event.
            callbacks.input_timeout()
            current_timeout = -1