Package asycamore :: Module dispatcher :: Class IDispatchTarget

Class IDispatchTarget



object --+
         |
        IDispatchTarget
Known Subclasses:
tcpsocket.AcceptingSocket, httpservice._ModelConnection

The minimal state for any asycamore.dispatch.IDispatchContext target

IDispatchTarget represents the minimal api and state that any dispatch target needs to maintain. IDispatchTarget is not usefull on its own. Derived or compatible classes must aditionaly provide implementations of the methods:

And should also provide an implementation of the IDispatchTarget.current_dispatch_filter method. The following classes all fully implement the above methods for different kinds of tcp socket usage:

dispatch_id should be the same value the operating system uses to identify the resource; ie socket.fileno(). Other values are permissable provided:

Note that implementations of close may use the value of dispatch_id for releasing the underlying resource.

dispatch_state is not inspected by the dispatch api in any way. Implementations are free to ommit this variable. All of the tcp based socket target support provided in this package makes use of this variable to store a representation of the connection state. Ie, 'connecting', 'accepting', 'idle' etc.



Instance Methods
 
close(self)
 
current_dispatch_filter(self)
Return a 3 tuple indicating the events you are interested in.
 
dispatch_event(self, event)
handle an event produced by a dispatcher.

Inherited from object: __delattr__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties
  dispatch_id
  dispatch_state

Inherited from object: __class__

Method Details

current_dispatch_filter(self)

 

Return a 3 tuple indicating the events you are interested in.

[OPTIONAL] implementations need not provide this method. If they do then they must honour the following semantics.

The values True, False and None are the only leagal values for each of R, W, E. The caller (eg., asycamore.dispatch.poll) maps this mask to the actual representation needed by the underlying OS system socket api. A value that evaluates True will result in the corresponding read, write, or exceptional event being enabled for the next poll, select of the socket state; A value that evaluates False (including None) will mask the associated event. False or None is how you spell: Do not signal me for this kind of event.

Disalowing explicit flag values in the rval of current_dispatch_filter is asymetrical with respect to the event tuple passed as argument to dispatch_event. dispatch_event implementations get the actual values as provided by the OS IO/api. However, in all cases none of the implementors of dispatch_event require anything other than truth or falshood semantics from that event, and acordingly do not make themselves depend on the exact values. Supporting OS specific masks as in the rvalue for current_dispatch_filter is trivialy suportable here but I dont want to encourage this. By default everything will use True, False or None. If a need for specific control arrises (libevent ?) then support can be added for that case without disturbing the defaults.

Returns:
(R, W, E)

dispatch_event(self, event)

 

handle an event produced by a dispatcher.

See: IDispatchContext.dispatch_once