spinnman.connections package¶
Subpackages¶
- spinnman.connections.abstract_classes package
- Submodules
- spinnman.connections.abstract_classes.connection module
- spinnman.connections.abstract_classes.eieio_receiver module
- spinnman.connections.abstract_classes.eieio_sender module
- spinnman.connections.abstract_classes.listenable module
- spinnman.connections.abstract_classes.multicast_receiver module
- spinnman.connections.abstract_classes.multicast_sender module
- spinnman.connections.abstract_classes.scp_receiver module
- spinnman.connections.abstract_classes.scp_sender module
- spinnman.connections.abstract_classes.sdp_receiver module
- spinnman.connections.abstract_classes.sdp_sender module
- spinnman.connections.abstract_classes.spinnaker_boot_receiver module
- spinnman.connections.abstract_classes.spinnaker_boot_sender module
- Module contents
- spinnman.connections.udp_packet_connections package
- Submodules
- spinnman.connections.udp_packet_connections.bmp_connection module
- spinnman.connections.udp_packet_connections.boot_connection module
- spinnman.connections.udp_packet_connections.eieio_connection module
- spinnman.connections.udp_packet_connections.ip_address_connection module
- spinnman.connections.udp_packet_connections.scamp_connection module
- spinnman.connections.udp_packet_connections.sdp_connection module
- spinnman.connections.udp_packet_connections.udp_connection module
- spinnman.connections.udp_packet_connections.udp_listenable_connection module
- spinnman.connections.udp_packet_connections.utils module
- Module contents
Submodules¶
spinnman.connections.connection_listener module¶
-
class
spinnman.connections.connection_listener.
ConnectionListener
(connection, n_processes=4, timeout=1)[source]¶ Bases:
threading.Thread
Thread that listens to a connection and calls callbacks with new messages when they arrive.
Parameters: - connection – An AbstractListenable connection to listen to
- n_processes – The number of threads to use when calling callbacks
- timeout – How long to wait for messages before checking to see if the connection is to be terminated.
-
add_callback
(callback)[source]¶ Add a callback to be called when a message is received
Parameters: callback (callable (connection message type -> None)) – A callable which takes a single parameter, which is the message received
-
close
()[source]¶ Closes the listener. Note that this does not close the provider of the messages; this instead marks the listener as closed. The listener will not truly stop until the get message call returns.
-
run
()[source]¶ Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
spinnman.connections.scp_request_pipeline module¶
-
class
spinnman.connections.scp_request_pipeline.
SCPRequestPipeLine
(connection, n_channels=1, intermediate_channel_waits=0, n_retries=10, packet_timeout=1.0)[source]¶ Bases:
object
Allows a set of SCP requests to be grouped together in a communication across a number of channels for a given connection.
This class implements an SCP windowing, first suggested by Andrew Mundy. This extends the idea by having both send and receive windows. These are represented by the n_channels and the intermediate_channel_waits parameters respectively. This seems to help with the timeout issue; when a timeout is received, all requests for which a reply has not been received can also timeout.
Parameters: - connection – The connection over which the communication is to take place
- n_channels – The number of requests to send before checking for responses. If None, this will be determined automatically
- intermediate_channel_waits – The number of outstanding responses to wait for before continuing sending requests. If None, this will be determined automatically
- n_retries – The number of times to resend any packet for any reason before an error is triggered
- packet_timeout – The number of elapsed seconds after sending a packet before it is considered a timeout.
-
finish
()[source]¶ Indicate the end of the packets to be sent. This must be called to ensure that all responses are received and handled.
-
n_channels
¶
-
n_resent
¶
-
n_retry_code_resent
¶
-
n_timeouts
¶
-
send_request
(request, callback, error_callback)[source]¶ Add an SCP request to the set to be sent
Parameters: - request – The SCP request to be sent
- callback – A callback function to call when the response has been received; takes SCPResponse as a parameter, or None if the response doesn’t need to be processed
- error_callback – A callback function to call when an error is found when processing the message; takes original AbstractSCPRequest, exception caught and a list of tuples of (filename, line number, function name, text) as a traceback
spinnman.connections.socket_address_with_chip module¶
-
class
spinnman.connections.socket_address_with_chip.
SocketAddressWithChip
(hostname, chip_x, chip_y, port_num=17893)[source]¶ Bases:
object
The address of a socket and an associated chip
-
chip_x
¶ The x-coordinate of the chip
Returns: the x-coordinate
-
chip_y
¶ The y-coordinate of the chip
Returns: the y-coordinate
-
hostname
¶ The hostname of the socket
Returns: the hostname
-
port_num
¶ The port number of the socket
Returns: the port
-
spinnman.connections.token_bucket module¶
-
class
spinnman.connections.token_bucket.
TokenBucket
(tokens, fill_rate)[source]¶ Bases:
object
An implementation of the token bucket algorithm. Usage:
>>> bucket = TokenBucket(80, 0.5) >>> print(bucket.consume(10)) True
Not thread safe.
Parameters: - tokens – the total tokens in the bucket
- fill_rate – the rate in tokens/second that the bucket will be refilled.
-
consume
(tokens, block=True)[source]¶ Consume tokens from the bucket. Returns True if there were sufficient tokens.
If there are not enough tokens and block is True, sleeps until the bucket is replenished enough to satisfy the deficiency.
If there are not enough tokens and block is False, returns False.
It is an error to consume more tokens than the bucket _capacity.
-
tokens
¶
Module contents¶
-
class
spinnman.connections.
ConnectionListener
(connection, n_processes=4, timeout=1)[source]¶ Bases:
threading.Thread
Thread that listens to a connection and calls callbacks with new messages when they arrive.
Parameters: - connection – An AbstractListenable connection to listen to
- n_processes – The number of threads to use when calling callbacks
- timeout – How long to wait for messages before checking to see if the connection is to be terminated.
-
add_callback
(callback)[source]¶ Add a callback to be called when a message is received
Parameters: callback (callable (connection message type -> None)) – A callable which takes a single parameter, which is the message received
-
close
()[source]¶ Closes the listener. Note that this does not close the provider of the messages; this instead marks the listener as closed. The listener will not truly stop until the get message call returns.
-
run
()[source]¶ Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
-
class
spinnman.connections.
SCPRequestPipeLine
(connection, n_channels=1, intermediate_channel_waits=0, n_retries=10, packet_timeout=1.0)[source]¶ Bases:
object
Allows a set of SCP requests to be grouped together in a communication across a number of channels for a given connection.
This class implements an SCP windowing, first suggested by Andrew Mundy. This extends the idea by having both send and receive windows. These are represented by the n_channels and the intermediate_channel_waits parameters respectively. This seems to help with the timeout issue; when a timeout is received, all requests for which a reply has not been received can also timeout.
Parameters: - connection – The connection over which the communication is to take place
- n_channels – The number of requests to send before checking for responses. If None, this will be determined automatically
- intermediate_channel_waits – The number of outstanding responses to wait for before continuing sending requests. If None, this will be determined automatically
- n_retries – The number of times to resend any packet for any reason before an error is triggered
- packet_timeout – The number of elapsed seconds after sending a packet before it is considered a timeout.
-
finish
()[source]¶ Indicate the end of the packets to be sent. This must be called to ensure that all responses are received and handled.
-
n_channels
¶
-
n_resent
¶
-
n_retry_code_resent
¶
-
n_timeouts
¶
-
send_request
(request, callback, error_callback)[source]¶ Add an SCP request to the set to be sent
Parameters: - request – The SCP request to be sent
- callback – A callback function to call when the response has been received; takes SCPResponse as a parameter, or None if the response doesn’t need to be processed
- error_callback – A callback function to call when an error is found when processing the message; takes original AbstractSCPRequest, exception caught and a list of tuples of (filename, line number, function name, text) as a traceback
-
class
spinnman.connections.
SocketAddressWithChip
(hostname, chip_x, chip_y, port_num=17893)[source]¶ Bases:
object
The address of a socket and an associated chip
-
chip_x
¶ The x-coordinate of the chip
Returns: the x-coordinate
-
chip_y
¶ The y-coordinate of the chip
Returns: the y-coordinate
-
hostname
¶ The hostname of the socket
Returns: the hostname
-
port_num
¶ The port number of the socket
Returns: the port
-
-
class
spinnman.connections.
TokenBucket
(tokens, fill_rate)[source]¶ Bases:
object
An implementation of the token bucket algorithm. Usage:
>>> bucket = TokenBucket(80, 0.5) >>> print(bucket.consume(10)) True
Not thread safe.
Parameters: - tokens – the total tokens in the bucket
- fill_rate – the rate in tokens/second that the bucket will be refilled.
-
consume
(tokens, block=True)[source]¶ Consume tokens from the bucket. Returns True if there were sufficient tokens.
If there are not enough tokens and block is True, sleeps until the bucket is replenished enough to satisfy the deficiency.
If there are not enough tokens and block is False, returns False.
It is an error to consume more tokens than the bucket _capacity.
-
tokens
¶