Module: cogen.core.reactors

Network polling code.

The reactor works in tandem with the socket operations. Here's the basic workflow:

  • the coroutine yields a operation
  • the scheduler runs that operation (the process method) Note: all the socket operations share the same process method.
    • if run_first is False then the operation is added in the reactor for polling (with the exception that if we have data in out internal buffers the operation is runned first)
    • if run_first is set (it's default) in the operation then in process method the reactor's run_or_add is called with the operation and coroutine

Note: run_first is a optimization hack really, first it tries to run the operation (this asumes the sockets are usualy ready) and if it raises any exceptions like EAGAIN, EWOULDBLOCK etc it adds that operation for polling (via select, epoll, kqueue etc) then the run method will be called only when select, epoll, kqueue says that the socket is ready.

Classes

EpollReactor

KQueueReactor

ReactorBase

A reactor just checks if there are ready-sockets for the operations. The operations are not done here, they are done in the socket ops instances.

SelectReactor