runtimepy.net package#
Subpackages#
- runtimepy.net.apps package
- Module contents
AppInfo
AppInfo.all_finalized()
AppInfo.config
AppInfo.config_param()
AppInfo.conn_manager
AppInfo.connections
AppInfo.exceptions()
AppInfo.logger
AppInfo.names
AppInfo.original_config()
AppInfo.peers
AppInfo.ports
AppInfo.raised_exception
AppInfo.result()
AppInfo.results
AppInfo.search()
AppInfo.search_structs()
AppInfo.search_tasks()
AppInfo.single()
AppInfo.stack
AppInfo.stop
AppInfo.structs
AppInfo.task_manager
AppInfo.tasks
AppInfo.tui
AppInfo.with_new_logger()
exception()
fail()
init_only()
noop()
wait_for_stop()
- Module contents
- runtimepy.net.arbiter package
- Subpackages
- Submodules
- runtimepy.net.arbiter.base module
- runtimepy.net.arbiter.info module
AppInfo
AppInfo.all_finalized()
AppInfo.config
AppInfo.config_param()
AppInfo.conn_manager
AppInfo.connections
AppInfo.exceptions()
AppInfo.logger
AppInfo.names
AppInfo.original_config()
AppInfo.peers
AppInfo.ports
AppInfo.raised_exception
AppInfo.result()
AppInfo.results
AppInfo.search()
AppInfo.search_structs()
AppInfo.search_tasks()
AppInfo.single()
AppInfo.stack
AppInfo.stop
AppInfo.structs
AppInfo.task_manager
AppInfo.tasks
AppInfo.tui
AppInfo.with_new_logger()
RuntimeStruct
SampleStruct
TrigStruct
- runtimepy.net.arbiter.result module
- runtimepy.net.arbiter.task module
- runtimepy.net.arbiter.udp module
- runtimepy.net.arbiter.websocket module
- Module contents
AppInfo
AppInfo.all_finalized()
AppInfo.config
AppInfo.config_param()
AppInfo.conn_manager
AppInfo.connections
AppInfo.exceptions()
AppInfo.logger
AppInfo.names
AppInfo.original_config()
AppInfo.peers
AppInfo.ports
AppInfo.raised_exception
AppInfo.result()
AppInfo.results
AppInfo.search()
AppInfo.search_structs()
AppInfo.search_tasks()
AppInfo.single()
AppInfo.stack
AppInfo.stop
AppInfo.structs
AppInfo.task_manager
AppInfo.tasks
AppInfo.tui
AppInfo.with_new_logger()
ArbiterTask
ArbiterTaskManager
ConnectionArbiter
TaskFactory
init_only()
- runtimepy.net.factories package
- Module contents
HttpConnection
HttpConnection.expecting_response
HttpConnection.get_handler()
HttpConnection.get_log_prefix()
HttpConnection.handlers
HttpConnection.identity
HttpConnection.init()
HttpConnection.log_alias
HttpConnection.post_handler()
HttpConnection.process_binary()
HttpConnection.request()
HttpConnection.request_json()
RuntimepyWebsocketConnection
RuntimepyWebsocketConnection.async_init()
RuntimepyWebsocketConnection.disable_extra()
RuntimepyWebsocketConnection.init()
RuntimepyWebsocketConnection.poll_connection_metrics
RuntimepyWebsocketConnection.poll_governor
RuntimepyWebsocketConnection.send_interfaces
RuntimepyWebsocketConnection.tab_sender()
RuntimepyWebsocketConnection.tabs
RuntimepyWebsocketConnection.ui_time
RuntimepyWebsocketJson
TcpConnection
TcpConnection.app()
TcpConnection.close()
TcpConnection.create_connection()
TcpConnection.create_pair()
TcpConnection.get_log_prefix()
TcpConnection.is_ssl
TcpConnection.log_alias
TcpConnection.log_prefix
TcpConnection.restart()
TcpConnection.send_binary()
TcpConnection.send_text()
TcpConnection.serve()
TcpConnection.uses_binary_tx_queue
TcpConnection.uses_text_tx_queue
TcpConnectionFactory
TcpEcho
TcpMessage
TcpMessageEcho
TcpNull
UdpConnection
UdpConnection.close()
UdpConnection.create_connection()
UdpConnection.create_pair()
UdpConnection.latest_rx_address
UdpConnection.log_alias
UdpConnection.process_datagram()
UdpConnection.restart()
UdpConnection.send_binary()
UdpConnection.send_text()
UdpConnection.sendto()
UdpConnection.set_remote_address()
UdpConnection.should_connect
UdpConnection.uses_binary_tx_queue
UdpConnection.uses_text_tx_queue
UdpConnectionFactory
UdpEcho
UdpMessage
UdpMessageEcho
UdpNull
WebsocketConnection
WebsocketConnectionFactory
WebsocketEcho
WebsocketNull
- Module contents
- runtimepy.net.html package
- runtimepy.net.http package
- runtimepy.net.server package
- Subpackages
- runtimepy.net.server.app package
- Subpackages
- Submodules
- runtimepy.net.server.app.base module
- runtimepy.net.server.app.create module
- runtimepy.net.server.app.elements module
- runtimepy.net.server.app.files module
- runtimepy.net.server.app.landing_page module
- runtimepy.net.server.app.placeholder module
- runtimepy.net.server.app.pyodide module
- runtimepy.net.server.app.sound module
- runtimepy.net.server.app.tab module
- Module contents
- runtimepy.net.server.struct package
- runtimepy.net.server.websocket package
- runtimepy.net.server.app package
- Submodules
- runtimepy.net.server.html module
- runtimepy.net.server.json module
- runtimepy.net.server.markdown module
- Module contents
RuntimepyServerConnection
RuntimepyServerConnection.add_path()
RuntimepyServerConnection.add_redirect_path()
RuntimepyServerConnection.apps
RuntimepyServerConnection.class_paths
RuntimepyServerConnection.class_redirect_paths
RuntimepyServerConnection.default_app
RuntimepyServerConnection.favicon_data
RuntimepyServerConnection.get_handler()
RuntimepyServerConnection.handle_command()
RuntimepyServerConnection.init()
RuntimepyServerConnection.json_data
RuntimepyServerConnection.log_paths()
RuntimepyServerConnection.paths
RuntimepyServerConnection.post_handler()
RuntimepyServerConnection.redirect_to()
RuntimepyServerConnection.render_markdown()
RuntimepyServerConnection.render_markdown_file()
RuntimepyServerConnection.try_file()
RuntimepyServerConnection.try_redirect()
package_data_dir()
- Subpackages
- runtimepy.net.stream package
- Subpackages
- Submodules
- runtimepy.net.stream.base module
- runtimepy.net.stream.string module
- Module contents
EchoMessageConnection
EchoTcpMessageConnection
EchoUdpMessageConnection
PrefixedMessageConnection
PrefixedMessageConnection.env
PrefixedMessageConnection.init()
PrefixedMessageConnection.logger
PrefixedMessageConnection.markdown
PrefixedMessageConnection.process_binary()
PrefixedMessageConnection.process_single()
PrefixedMessageConnection.processor
PrefixedMessageConnection.send_message()
PrefixedMessageConnection.send_message_str()
StringMessageConnection
TcpPrefixedMessageConnection
TcpStringMessageConnection
UdpPrefixedMessageConnection
UdpStringMessageConnection
- runtimepy.net.tcp package
- Subpackages
- Submodules
- runtimepy.net.tcp.connection module
EchoTcpConnection
NullTcpConnection
TcpConnection
TcpConnection.app()
TcpConnection.close()
TcpConnection.create_connection()
TcpConnection.create_pair()
TcpConnection.env
TcpConnection.get_log_prefix()
TcpConnection.is_ssl
TcpConnection.log_alias
TcpConnection.log_prefix
TcpConnection.logger
TcpConnection.markdown
TcpConnection.remote_address
TcpConnection.restart()
TcpConnection.send_binary()
TcpConnection.send_text()
TcpConnection.serve()
TcpConnection.uses_binary_tx_queue
TcpConnection.uses_text_tx_queue
- runtimepy.net.tcp.create module
- runtimepy.net.tcp.protocol module
- Module contents
EchoTcpConnection
NullTcpConnection
TcpConnection
TcpConnection.app()
TcpConnection.close()
TcpConnection.create_connection()
TcpConnection.create_pair()
TcpConnection.env
TcpConnection.get_log_prefix()
TcpConnection.is_ssl
TcpConnection.log_alias
TcpConnection.log_prefix
TcpConnection.logger
TcpConnection.markdown
TcpConnection.remote_address
TcpConnection.restart()
TcpConnection.send_binary()
TcpConnection.send_text()
TcpConnection.serve()
TcpConnection.uses_binary_tx_queue
TcpConnection.uses_text_tx_queue
- runtimepy.net.udp package
- Subpackages
- Submodules
- runtimepy.net.udp.connection module
EchoUdpConnection
NullUdpConnection
UdpConnection
UdpConnection.close()
UdpConnection.create_connection()
UdpConnection.create_pair()
UdpConnection.env
UdpConnection.latest_rx_address
UdpConnection.log_alias
UdpConnection.logger
UdpConnection.markdown
UdpConnection.process_datagram()
UdpConnection.remote_address
UdpConnection.restart()
UdpConnection.send_binary()
UdpConnection.send_text()
UdpConnection.sendto()
UdpConnection.set_remote_address()
UdpConnection.should_connect
UdpConnection.uses_binary_tx_queue
UdpConnection.uses_text_tx_queue
- runtimepy.net.udp.create module
- runtimepy.net.udp.protocol module
- runtimepy.net.udp.queue module
- Module contents
EchoUdpConnection
NullUdpConnection
QueueUdpConnection
UdpConnection
UdpConnection.close()
UdpConnection.create_connection()
UdpConnection.create_pair()
UdpConnection.env
UdpConnection.latest_rx_address
UdpConnection.log_alias
UdpConnection.logger
UdpConnection.markdown
UdpConnection.process_datagram()
UdpConnection.remote_address
UdpConnection.restart()
UdpConnection.send_binary()
UdpConnection.send_text()
UdpConnection.sendto()
UdpConnection.set_remote_address()
UdpConnection.should_connect
UdpConnection.uses_binary_tx_queue
UdpConnection.uses_text_tx_queue
- runtimepy.net.websocket package
Submodules#
runtimepy.net.backoff module#
A module implementing a simple exponential-backoff interface.
- class runtimepy.net.backoff.ExponentialBackoff(interval: float = 0.1, max_sleep: float = 10.0, max_tries: int = 20)[source]#
Bases:
object
A class implementing a simple exponential-backoff handler.
- attempt: int#
- property give_up: bool#
Determine whether or not to give up based on the number of attempts.
- wait: float#
runtimepy.net.connection module#
A module implementing a network-connection interface.
- class runtimepy.net.connection.Connection(logger: Logger | LoggerAdapter[Any], env: ChannelEnvironment = None, add_metrics: bool = True, markdown: str = None)[source]#
Bases:
LoggerMixinLevelControl
,ChannelEnvironmentMixin
,MarkdownMixin
,ABC
A connection interface.
- property auto_restart: bool#
Determine if this connection should be automatically restarted.
- connected = True#
- default_auto_restart = False#
- property disabled: bool#
Determine if this connection is disabled.
- async process(stop_sig: Event = None, disable_time: float = None, backoff: ExponentialBackoff = None) None [source]#
Process tasks for this connection while the connection is active.
- process_then_disable(**kwargs) AsyncIterator[None] [source]#
Process this connection, then disable and wait for completion.
- async restart() bool [source]#
Reset necessary underlying state for this connection to ‘process’ again.
- property tasks: Iterator[Task[None]]#
Get active connection tasks. Instance uses this opportunity to release references to any completed tasks.
- uses_binary_tx_queue = True#
- uses_text_tx_queue = True#
- class runtimepy.net.connection.EchoConnection(logger: Logger | LoggerAdapter[Any], env: ChannelEnvironment = None, add_metrics: bool = True, markdown: str = None)[source]#
Bases:
Connection
A connection that just echoes what it was sent.
- class runtimepy.net.connection.NullConnection(logger: Logger | LoggerAdapter[Any], env: ChannelEnvironment = None, add_metrics: bool = True, markdown: str = None)[source]#
Bases:
Connection
A connection that doesn’t do anything with incoming data.
runtimepy.net.manager module#
A module implementing a connection manager.
- class runtimepy.net.manager.ConnectionManager[source]#
Bases:
LoggerMixin
A class for managing connection processing at runtime.
- property connection_tasks: Iterator[Task[None]]#
Iterate over connection tasks.
- async manage(stop_sig: Event) None [source]#
Handle incoming connections until the stop signal is set.
- property num_connections: int#
Return the number of managed connections.
runtimepy.net.mixin module#
Various networking-related class utilities.
- class runtimepy.net.mixin.BinaryMessageQueueMixin[source]#
Bases:
object
A mixin for adding a ‘queue’ attribute.
- class runtimepy.net.mixin.TransportMixin(transport: BaseTransport)[source]#
Bases:
object
A class simplifying evaluation of local and remote addresses.
- mtu(probe_size: int = 1432, fallback: int = 1500, probe_create: ~typing.Callable[[int], bytes] = <class 'bytes'>) int [source]#
Get a maximum transmission unit for this connection. Underlying sockets must be connected for this to work.
- property socket: socket#
Get this instance’s underlying socket.
runtimepy.net.mtu module#
A module implementing utilities for calculating maximum transmission-unit sizes.
- class runtimepy.net.mtu.SocketConstants(*values)[source]#
Bases:
IntEnum
Some platform definitions necessary for mtu discovery.
- IP_MTU = 14#
- IP_MTU_DISCOVER = 10#
- IP_PMTUDISC_DO = 2#
- runtimepy.net.mtu.discover_mtu(*destination: str | int | ~runtimepy.net.util.IPv4Host | ~runtimepy.net.util.IPv6Host | None, local: ~runtimepy.net.util.IPv4Host | ~runtimepy.net.util.IPv6Host = None, probe_size: int = 1432, fallback: int = 1500, kind: int = SocketKind.SOCK_DGRAM, probe_create: ~typing.Callable[[int], bytes] = <class 'bytes'>) int [source]#
Determine the maximum transmission unit for an IPv4 payload to a provided host.
- runtimepy.net.mtu.host_discover_mtu(local: ~runtimepy.net.util.IPv4Host | ~runtimepy.net.util.IPv6Host, destination: ~runtimepy.net.util.IPv4Host | ~runtimepy.net.util.IPv6Host, probe_size: int, fallback: int, kind: int = SocketKind.SOCK_DGRAM, probe_create: ~typing.Callable[[int], bytes] = <class 'bytes'>) int [source]#
Perform MTU discovery given a local and remote host plus probe size.
runtimepy.net.ssl module#
A module implementing SSL-related interfaces.
runtimepy.net.util module#
A module implementing various networking utilities.
- class runtimepy.net.util.IPv4Host(name: str = '', port: int = 0)[source]#
Bases:
NamedTuple
See: https://docs.python.org/3/library/socket.html#socket-families.
- property address: IPv4Address#
Get an address object for this hostname.
- property address_str: str#
Get an address string for this host.
- property address_str_tuple: tuple[str, int]#
Get a string-address tuple for this instance.
- property family: int#
Address family constant.
- property hostname: str#
Get a hostname for this instance.
- name: str#
Alias for field number 0
- port: int#
Alias for field number 1
- class runtimepy.net.util.IPv6Host(name: str = '', port: int = 0, flowinfo: int = 0, scope_id: int = 0)[source]#
Bases:
NamedTuple
See: https://docs.python.org/3/library/socket.html#socket-families.
- property address: IPv6Address#
Get an address object for this hostname.
- property address_str: str#
Get an address string for this host.
- property address_str_tuple: tuple[str, int, int, int]#
Get a string-address tuple for this instance.
- property family: int#
Address family constant.
- flowinfo: int#
Alias for field number 2
- property hostname: str#
Get a hostname for this instance.
- name: str#
Alias for field number 0
- port: int#
Alias for field number 1
- scope_id: int#
Alias for field number 3
- runtimepy.net.util.address_str(name: str, fallback_host: str = 'localhost', **kwargs) str [source]#
Get an IP address string for a given name.
- runtimepy.net.util.get_free_socket(local: IPv4Host | IPv6Host = None, kind: int = SocketKind.SOCK_STREAM, reuse: bool = False) socket [source]#
Attempt to get an available socket.
- runtimepy.net.util.get_free_socket_name(local: IPv4Host | IPv6Host = None, kind: int = SocketKind.SOCK_STREAM) IPv4Host | IPv6Host [source]#
Create a socket to determine an arbitrary port number that’s available. There is an inherent race condition using this strategy.
- runtimepy.net.util.hostname(ip_address: str) str [source]#
Attempt to get a string hostname for a string IP address argument that ‘gethostbyaddr’ accepts. Otherwise return the original string
- runtimepy.net.util.hostname_port(ip_address: str, port: int) str [source]#
Get a hostname string with a port appended.
- runtimepy.net.util.normalize_host(*args: str | int | ~runtimepy.net.util.IPv4Host | ~runtimepy.net.util.IPv6Host | None, default: type[~runtimepy.net.util.IPv4Host | ~runtimepy.net.util.IPv6Host] = <class 'runtimepy.net.util.IPv4Host'>) IPv4Host | IPv6Host [source]#
Get a host object from caller parameters.
Module contents#
A module aggregating commonly used networking interface.
- class runtimepy.net.Connection(logger: Logger | LoggerAdapter[Any], env: ChannelEnvironment = None, add_metrics: bool = True, markdown: str = None)[source]#
Bases:
LoggerMixinLevelControl
,ChannelEnvironmentMixin
,MarkdownMixin
,ABC
A connection interface.
- property auto_restart: bool#
Determine if this connection should be automatically restarted.
- connected = True#
- default_auto_restart = False#
- property disabled: bool#
Determine if this connection is disabled.
- env: ChannelEnvironment#
- logger: LoggerType#
- markdown: str#
- async process(stop_sig: Event = None, disable_time: float = None, backoff: ExponentialBackoff = None) None [source]#
Process tasks for this connection while the connection is active.
- process_then_disable(**kwargs) AsyncIterator[None] [source]#
Process this connection, then disable and wait for completion.
- async restart() bool [source]#
Reset necessary underlying state for this connection to ‘process’ again.
- property tasks: Iterator[Task[None]]#
Get active connection tasks. Instance uses this opportunity to release references to any completed tasks.
- uses_binary_tx_queue = True#
- uses_text_tx_queue = True#
- class runtimepy.net.ConnectionManager[source]#
Bases:
LoggerMixin
A class for managing connection processing at runtime.
- property connection_tasks: Iterator[Task[None]]#
Iterate over connection tasks.
- async manage(stop_sig: Event) None [source]#
Handle incoming connections until the stop signal is set.
- property num_connections: int#
Return the number of managed connections.
- class runtimepy.net.EchoConnection(logger: Logger | LoggerAdapter[Any], env: ChannelEnvironment = None, add_metrics: bool = True, markdown: str = None)[source]#
Bases:
Connection
A connection that just echoes what it was sent.
- class runtimepy.net.ExponentialBackoff(interval: float = 0.1, max_sleep: float = 10.0, max_tries: int = 20)[source]#
Bases:
object
A class implementing a simple exponential-backoff handler.
- attempt: int#
- property give_up: bool#
Determine whether or not to give up based on the number of attempts.
- wait: float#
- class runtimepy.net.IPv4Host(name: str = '', port: int = 0)[source]#
Bases:
NamedTuple
See: https://docs.python.org/3/library/socket.html#socket-families.
- property address: IPv4Address#
Get an address object for this hostname.
- property address_str: str#
Get an address string for this host.
- property address_str_tuple: tuple[str, int]#
Get a string-address tuple for this instance.
- property family: int#
Address family constant.
- property hostname: str#
Get a hostname for this instance.
- name: str#
Alias for field number 0
- port: int#
Alias for field number 1
- class runtimepy.net.IPv6Host(name: str = '', port: int = 0, flowinfo: int = 0, scope_id: int = 0)[source]#
Bases:
NamedTuple
See: https://docs.python.org/3/library/socket.html#socket-families.
- property address: IPv6Address#
Get an address object for this hostname.
- property address_str: str#
Get an address string for this host.
- property address_str_tuple: tuple[str, int, int, int]#
Get a string-address tuple for this instance.
- property family: int#
Address family constant.
- flowinfo: int#
Alias for field number 2
- property hostname: str#
Get a hostname for this instance.
- name: str#
Alias for field number 0
- port: int#
Alias for field number 1
- scope_id: int#
Alias for field number 3
- class runtimepy.net.NullConnection(logger: Logger | LoggerAdapter[Any], env: ChannelEnvironment = None, add_metrics: bool = True, markdown: str = None)[source]#
Bases:
Connection
A connection that doesn’t do anything with incoming data.
- runtimepy.net.get_free_socket(local: IPv4Host | IPv6Host = None, kind: int = SocketKind.SOCK_STREAM, reuse: bool = False) socket [source]#
Attempt to get an available socket.
- runtimepy.net.get_free_socket_name(local: IPv4Host | IPv6Host = None, kind: int = SocketKind.SOCK_STREAM) IPv4Host | IPv6Host [source]#
Create a socket to determine an arbitrary port number that’s available. There is an inherent race condition using this strategy.
- runtimepy.net.hostname(ip_address: str) str [source]#
Attempt to get a string hostname for a string IP address argument that ‘gethostbyaddr’ accepts. Otherwise return the original string
- runtimepy.net.normalize_host(*args: str | int | ~runtimepy.net.util.IPv4Host | ~runtimepy.net.util.IPv6Host | None, default: type[~runtimepy.net.util.IPv4Host | ~runtimepy.net.util.IPv6Host] = <class 'runtimepy.net.util.IPv4Host'>) IPv4Host | IPv6Host [source]#
Get a host object from caller parameters.