pyopticon._system._socket_widget module

class pyopticon._system._socket_widget.SocketWidget(parent_dashboard, port_numbers)

Bases: object

This widget manages socket connections from external Python programs. It displays how many sockets are connected and has a few other useful functions.

Parameters:
_change_socket_counter(change)

Changes the socket counter displayed on the screen and updates the display and frame color accordingly.

Parameters:

change (int) – Value to add to the socket counter (+1 or -1)

_increment_socket_counter()

Increments the socket connection counter in a thread-safe way.

_decrement_socket_counter()

Decrements the socket connection counter in a thread-safe way.

get_frame()

Get the tkinter frame on which this object is drawn.

Returns:

The widget’s tkinter frame

Return type:

tkinter.Frame

_shutdown_threads()

Sets a flag that tells the socket processing threads to close themselves at program shutdown.

_run_one_thread(which_port)

Launch a thread that listens on a port for socket connections, handles the various types of commands that may be received on that socket, and shuts down the socket and thread on program close. Also handles ports that are ‘left hanging’ when a client crashes or disconnects without sending a ‘Close’ method.

Parameters:

which_port (int) – The port on which this thread will listen.

_force_disconnect()

Force any connected sockets to disconnect, resulting in broken pipe exceptions on the client side.