Package ganeti :: Module daemon :: Class AsyncTerminatedMessageStream
[hide private]
[frames] | no frames]

Class AsyncTerminatedMessageStream

source code


A terminator separated message stream asyncore module.

Handles a stream connection receiving messages terminated by a defined separator. For each complete message handle_message is called.

Instance Methods [hide private]
 
__init__(self, connected_socket, peer_address, terminator, family, unhandled_limit)
AsyncTerminatedMessageStream constructor.
source code
 
collect_incoming_data(self, data) source code
 
_can_handle_message(self) source code
 
found_terminator(self) source code
 
handle_message(self, message, message_id)
Handle a terminated message.
source code
 
send_message(self, message)
Send a message to the remote peer.
source code
 
readable(self)
predicate for inclusion in the readable for select()
source code
 
writable(self)
predicate for inclusion in the writable for select()
source code
 
handle_write(self) source code
 
close_log(self) source code
 
handle_expt(self) source code
 
handle_error(self)
Log an error in handling any request, and proceed.
source code

Inherited from asynchat.async_chat: close_when_done, discard_buffers, get_terminator, handle_close, handle_read, initiate_send, push, push_with_producer, set_terminator

Inherited from asynchat.async_chat (private): _collect_incoming_data, _get_data

Inherited from asyncore.dispatcher: __getattr__, __repr__, accept, add_channel, bind, close, connect, create_socket, del_channel, handle_accept, handle_connect, handle_connect_event, handle_expt_event, handle_read_event, handle_write_event, listen, log, log_info, recv, send, set_reuse_addr, set_socket

Class Variables [hide private]

Inherited from asynchat.async_chat: ac_in_buffer_size, ac_out_buffer_size

Inherited from asyncore.dispatcher: accepting, addr, closing, connected, debug, ignore_log_types

Method Details [hide private]

__init__(self, connected_socket, peer_address, terminator, family, unhandled_limit)
(Constructor)

source code 

AsyncTerminatedMessageStream constructor.

Parameters:
  • connected_socket (socket.socket) - connected stream socket to receive messages from
  • peer_address - family-specific peer address
  • terminator (string) - terminator separating messages in the stream
  • family (integer) - socket family
  • unhandled_limit (integer or None) - maximum unanswered messages
Overrides: asyncore.dispatcher.__init__

collect_incoming_data(self, data)

source code 
Overrides: asynchat.async_chat.collect_incoming_data

found_terminator(self)

source code 
Overrides: asynchat.async_chat.found_terminator

handle_message(self, message, message_id)

source code 

Handle a terminated message.

Parameters:
  • message (string) - message to handle
  • message_id (integer) - stream's message sequence number

send_message(self, message)

source code 

Send a message to the remote peer. This function is thread-safe.

Parameters:
  • message (string) - message to send, without the terminator

Warning: If calling this function from a thread different than the one performing the main asyncore loop, remember that you have to wake that one up.

readable(self)

source code 

predicate for inclusion in the readable for select()

Overrides: asyncore.dispatcher.readable

writable(self)

source code 

predicate for inclusion in the writable for select()

Overrides: asyncore.dispatcher.writable

handle_write(self)

source code 
Overrides: asyncore.dispatcher.handle_write

handle_expt(self)

source code 
Overrides: asyncore.dispatcher.handle_expt

handle_error(self)

source code 

Log an error in handling any request, and proceed.

Overrides: asyncore.dispatcher.handle_error