Package ganeti :: Package rpc :: Module transport :: Class Transport
[hide private]
[frames] | no frames]

Class Transport

source code

Low-level transport class.

This is used on the client side.

This could be replace by any other class that provides the same semantics to the Client. This means:

Instance Methods [hide private]
 
__init__(self, address, timeouts=None)
Constructor for the Client class.
source code
 
_CheckSocket(self)
Make sure we are connected.
source code
 
Send(self, msg)
Send a message.
source code
 
Recv(self)
Try to receive a message from the socket.
source code
 
Call(self, msg)
Send a message and wait for the response.
source code
 
Close(self)
Close the socket
source code
Static Methods [hide private]
 
_Connect(sock, address, timeout) source code
Method Details [hide private]

__init__(self, address, timeouts=None)
(Constructor)

source code 

Constructor for the Client class.

Arguments:

  • address: a valid address the the used transport class
  • timeout: a list of timeouts, to be used on connect and read/write

There are two timeouts used since we might want to wait for a long time for a response, but the connect timeout should be lower.

If not passed, we use a default of 10 and respectively 60 seconds.

Note that on reading data, since the timeout applies to an invidual receive, it might be that the total duration is longer than timeout value passed (we make a hard limit at twice the read timeout).

Send(self, msg)

source code 

Send a message.

This just sends a message and doesn't wait for the response.

Recv(self)

source code 

Try to receive a message from the socket.

In case we already have messages queued, we just return from the queue. Otherwise, we try to read data with a _rwtimeout network timeout, and making sure we don't go over 2x_rwtimeout as a global limit.

Call(self, msg)

source code 

Send a message and wait for the response.

This is just a wrapper over Send and Recv.