Constructor

Class: cogen.core.sockets.SocketOperation

This is a generic class for a operation that involves some socket call.

A socket operation should subclass WriteOperation or ReadOperation, define a run method and call the __init__ method of the superclass.

Constructor

__init__ (self, sock, run_first=True, **kws)

All the socket operations have these generic properties that the poller and scheduler interprets:

  • timeout - the ammout of time in seconds or timedelta, or the datetime value till the poller should wait for this operation.
  • weak_timeout - if this is True the timeout handling code will take into account the time of last activity (that would be the time of last try_run call)
  • prio - a flag for the scheduler

Methods

cleanup (self, sched, coro)

finalize (self)

Called just before the Coroutine wrapper passes the operation back in the generator. Return value is the value actualy sent in the generator. Subclasses might overwrite this method and call it from the superclass.

pending (self)

process (self, sched, coro)

Add the operation in the reactor if necessary.

run (self, reactor)

set_timeout (self, val)

try_run (self, reactor)

This method will return a None value or raise a exception if the operation can't complete at this time.

The socket poller will run this method if the socket is readable/writeable.

If this returns a value that evaluates to False, the poller will try to run this at a later time (when the socket is readable/writeable again).

Attributes

addr

Value of addr

<member 'addr' of 'SocketOperation' objects>

buff

Value of buff

<member 'buff' of 'SocketOperation' objects>

coro

Value of coro

<member 'coro' of 'TimedOperation' objects>

delta

Value of delta

<member 'delta' of 'TimedOperation' objects>

fileno

Value of fileno

<member 'fileno' of 'SocketOperation' objects>

last_checkpoint

Value of last_checkpoint

<member 'last_checkpoint' of 'TimedOperation' objects>

last_update

Value of last_update

<member 'last_update' of 'SocketOperation' objects>

len

Value of len

<member 'len' of 'SocketOperation' objects>

prio

Value of prio

<member 'prio' of 'Operation' objects>

run_first

Value of run_first

<member 'run_first' of 'SocketOperation' objects>

sock

Value of sock

<member 'sock' of 'SocketOperation' objects>

state

Value of state

<member 'state' of 'Operation' objects>

timeout

Value of timeout

<member 'timeout' of 'TimedOperation' objects>

trim

Value of trim

2000

weak_timeout

Value of weak_timeout

<member 'weak_timeout' of 'TimedOperation' objects>