Limpet - a mechanism for proxying KBUS messages to/from another Limpet.
This allows messages to be communicated from one KBUS device to another, either on the same machine or over a network.
See also the LimpetExample class, which shows how a limpet might be deployed in practise.
Bases: kbus.ksock.Ksock
A Limpet proxies KBUS messages to/from another Limpet.
This class wraps itself around a Ksock, transforming messages as they are read from the Ksock, or written to it.
Not meaningful for this class.
If a send to our Ksock failed, call this to generate a message.
‘msg’ is the message we tried to send.
‘exc’ is the IOError exception that was raised by the failed call of ‘send_msg()’
We return an appropriate message to send to the other Limpet, or None if we could not determine one.
Not meaningful for this class.
We only support reading an entire message in one go with read_next_msg().
Not meaningful for this class.
We only support reading an entire message in one go with read_next_msg().
Not meaningful for this class.
We only support reading an entire message in one go with read_next_msg().
Read a Message of length length bytes.
It is assumed that length was returned by a previous call of next_msg(). It must be large enough to cause the entire message to be read.
After the data has been read, it is passed to Message() to construct a message instance, which is returned.
Returns None if there was nothing to be read, or if the message read is one that this Limpet should ignore.
Read the next Message completely.
Equivalent to a call of kbus.Ksock.next_msg(), followed by reading the appropriate number of bytes and passing that to Message() to construct a message instance, which is returned.
Returns None if there was nothing to be read, or if the message read is one that this Limpet should ignore.
Not meaningful for this class.
Limpets require this option to be set in order to work properly, and do not allow the user to change it.
Write a Message (from the other Limpet) to our Ksock, and send it.
Entirely equivalent to calling write_msg() and then send(), and returns the MessageId of the sent message, like send() does.
If the message was one we need to ignore (i.e., we’re not interested in sending it), raises NoMessage.
If we need to send a message back to the other Limpet, then that exception will have the messsage as its argument.
Not meaningful for this class.
Not meaningful for this class.
Limpets require this option to be set in order to work properly, and do not allow the user to change it.
Not meaningful for this class.
We only support writing an entire message in one go with send_msg().
Not meaningful for this class.
We only support writing and sending an entire message in one go with send_msg().
Run a Limpet.
A Limpet has two “ends”:
Messages received from KBUS get sent to the other Limpet.
Messages sent from the other Limpet get sent to KBUS.
Bases: exceptions.Exception
Signifies a fatal condition such as a failure to connect to the other Limpet, or when the termination_message of a LimpetKsock is read.
Bases: exceptions.Exception
The other end has closed its end of the socket.
Bases: exceptions.Exception
There was no message.
Bases: exceptions.Exception
We have read a badly formatted KBUS message.
Bases: exceptions.Exception
Something went wrong trying to send a message to KBUS.
There is an error message, for sending back to the other Limpet, in our .error value.
Work out what sort of address we have.
Returns (address, family).
Connect to a socket as a server.
We start listening, until we get someone connecting to us.
Returns a tuple (listener_socket, connection_socket).
Connect to a socket as a client.
Returns the socket.
Attempts to clean up a socket whose address is a file in the filesystem. This currently only applies to sockets of the AF_UNIX family.