Idle
— Idle watcher¶
-
class
Idle
(loop, callback[, data=None, priority=0])¶ Parameters: Idle
watchers trigger events when no other events of the same or higher priority are pending (Prepare
,Check
and otherIdle
watchers do not count as receiving “events”).That is, as long as your process is busy handling sockets or timeouts (or even signals, imagine) of the same or higher priority it will not be triggered. But when your process is idle (or only lower-priority watchers are pending), the idle watchers are being called once per event loop iteration - until stopped, that is, or your process receives more events and becomes busy again with higher priority stuff.
The most noteworthy effect is that as long as any
Idle
watchers are active, the process will not block when waiting for new events.Apart from keeping your process non-blocking (which is a useful effect on its own sometimes),
Idle
watchers are a good place to do “pseudo-background processing”, or delay processing stuff to after the event loop has handled all outstanding events.