-
-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Description
The Input class is like a reactor:
You can schedule events for the future (timers)
Lines 330 to 341 in 307aa87
| def scheduled_event_trigger( | |
| self, event_type: Type[events.ScheduledEvent] | |
| ) -> Callable[[float], None]: | |
| """Returns a callback that schedules events for the future. | |
| Returned callback function will add an event of type event_type | |
| to a queue which will be checked the next time an event is requested.""" | |
| def callback(when: float) -> None: | |
| self.queued_scheduled_events.append((when, event_type(when=when))) | |
| return callback |
It uses select()
Lines 173 to 180 in 307aa87
| (rs, _, _) = select.select( | |
| [self.in_stream.fileno()] | |
| + ([] if self.wakeup_read_fd is None else [self.wakeup_read_fd]) | |
| + self.readers, | |
| [], | |
| [], | |
| remaining_timeout, | |
| ) |
But it's still a "you call it," not an "it calls you" interface: you're supposed to iterate over it, but you can do as much work as you want before you call next(input) again.
To integrate event loops, these timers will need to be delegated to the real event loop as will checking whether stdin is ready.
Specifically, Twisted's reactors, specifically specifically cfreactor and gireactor.
Metadata
Metadata
Assignees
Labels
No labels