Package pike :: Module transport :: Class BasePoller
[hide private]
[frames] | no frames]

Class BasePoller

source code

object --+
         |
        BasePoller
Known Subclasses:

A poller is an underlying event monitoring system. This generic class can be built upon to implement efficient file descriptor polling methods which are available on various platforms.

A minimal subclass must implement the poll() function which performs a single iteration of the event loop across all monitored Transports and calls process_readables and process_writables with the correct values.

Subclasses should, in most cases call, into BasePoller methods in order to maintain proper accounting structures. The exception is when the poller handles accounting itself.

Instance Methods [hide private]
 
__init__(self)
initialize the poller and register any kernel global structures necessary to monitor the file descriptors
source code
 
add_channel(self, transport)
begin monitoring the transport socket for read/connect events
source code
 
del_channel(self, transport)
stop monitoring the transport socket
source code
 
defer_write(self, transport)
defers a write on the given transport.
source code
 
loop(self, timeout=None, count=None)
enter the async event loop for the given timeout or number of iterations
source code
 
poll(self)
Must be implemented by subclasses to execute a single iteration of the event loop.
source code
 
process_readables(self, readables)
call handle_read on each applicable fd in the readables sequence and subsequently handle_error if any exception is raised or handle_close if the underlying socket is no longer connected
source code
 
process_writables(self, writables)
for each Transport t corresponding to an fd in the writables sequence,...
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

initialize the poller and register any kernel global structures necessary to monitor the file descriptors

Overrides: object.__init__

add_channel(self, transport)

source code 

begin monitoring the transport socket for read/connect events

the underlying poller should not monitor Transports for writability
except when:
    * the Transport's connection has not yet been established
    * the Transport has been passed as an argument to defer_write

defer_write(self, transport)

source code 

defers a write on the given transport. once the async poller determines that the transport can be written to, handle_write will be called

poll(self)

source code 

Must be implemented by subclasses to execute a single iteration of the
event loop. Based on the outcome of the events, the following actions
MUST be performed

    * process_readables is called with a list of file descriptors which
      have data available for reading
    * process_writables is called with a list of file descriptors which
      have data available for writing

process_writables(self, writables)

source code 

for each Transport t corresponding to an fd in the writables sequence,
    if t is not marked as connected, call handle_connect_event
    otherwise call handle_write and remove the Transport from the set
    of deferred writers
    process close and error events if exception is encountered