Class: cogen.core.sockets.SendFile
Uses underling OS sendfile call or a regular memory copy operation if there is no sendfile. You can use this as a WriteAll if you specify the length. Usage:
yield sockets.SendFile(file_object, socket_object, 0, blocksize=0) # there will be only one send operation (if successfull) # that meas the whole file will be read in memory if there is #no sendfile yield sockets.SendFile(file_object, socket_object, 0, file_size) # this will hang if we can't read file_size bytes #from the file
Constructor
__init__ (self, file_handle, sock, offset=None, length=None, blocksize=4096, **kws)
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.
iocp (self, overlap)
iocp_done (self, rc, nbytes)
iocp_send (self, offset, length, overlap)
pending (self)
process (self, sched, coro)
Add the operation in the reactor if necessary.
run (self, reactor)
send (self, offset, length)
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>
blocksize
Value of blocksize
<member 'blocksize' of 'SendFile' objects>
buff
Value of buff
<member 'buff' of 'SocketOperation' objects>
file_handle
Value of file_handle
<member 'file_handle' of 'SendFile' objects>
fileno
Value of fileno
<member 'fileno' of 'SocketOperation' objects>
last_update
Value of last_update
<member 'last_update' of 'SocketOperation' objects>
len
Value of len
<member 'len' of 'SocketOperation' objects>
length
Value of length
<member 'length' of 'SendFile' objects>
offset
Value of offset
<member 'offset' of 'SendFile' objects>
position
Value of position
<member 'position' of 'SendFile' objects>
prio
Value of prio
<member 'prio' of 'Operation' objects>
run_first
Value of run_first
<member 'run_first' of 'SocketOperation' objects>
sent
Value of sent
<member 'sent' of 'SendFile' objects>
sock
Value of sock
<member 'sock' of 'SocketOperation' objects>
state
Value of state
<member 'state' of 'Operation' objects>
trim
Value of trim
2000
weak_timeout
Value of weak_timeout
<member 'weak_timeout' of 'TimedOperation' objects>