runtimepy.net package#
Subpackages#
- runtimepy.net.apps package
- Module contents
AppInfoAppInfo.all_finalized()AppInfo.configAppInfo.config_param()AppInfo.conn_managerAppInfo.connectionsAppInfo.exceptions()AppInfo.loggerAppInfo.namesAppInfo.original_config()AppInfo.peersAppInfo.portsAppInfo.raised_exceptionAppInfo.result()AppInfo.resultsAppInfo.search()AppInfo.search_structs()AppInfo.search_tasks()AppInfo.single()AppInfo.stackAppInfo.stopAppInfo.structsAppInfo.task_managerAppInfo.tasksAppInfo.tuiAppInfo.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
AppInfoAppInfo.all_finalized()AppInfo.configAppInfo.config_param()AppInfo.conn_managerAppInfo.connectionsAppInfo.exceptions()AppInfo.loggerAppInfo.namesAppInfo.original_config()AppInfo.peersAppInfo.portsAppInfo.raised_exceptionAppInfo.result()AppInfo.resultsAppInfo.search()AppInfo.search_structs()AppInfo.search_tasks()AppInfo.single()AppInfo.stackAppInfo.stopAppInfo.structsAppInfo.task_managerAppInfo.tasksAppInfo.tuiAppInfo.with_new_logger()
RuntimeStructSampleStructTrigStruct
- runtimepy.net.arbiter.result module
- runtimepy.net.arbiter.task module
- runtimepy.net.arbiter.udp module
- runtimepy.net.arbiter.websocket module
- Module contents
AppInfoAppInfo.all_finalized()AppInfo.configAppInfo.config_param()AppInfo.conn_managerAppInfo.connectionsAppInfo.exceptions()AppInfo.loggerAppInfo.namesAppInfo.original_config()AppInfo.peersAppInfo.portsAppInfo.raised_exceptionAppInfo.result()AppInfo.resultsAppInfo.search()AppInfo.search_structs()AppInfo.search_tasks()AppInfo.single()AppInfo.stackAppInfo.stopAppInfo.structsAppInfo.task_managerAppInfo.tasksAppInfo.tuiAppInfo.with_new_logger()
ArbiterTaskArbiterTaskManagerConnectionArbiterTaskFactoryinit_only()
- runtimepy.net.factories package
- Module contents
HttpConnectionHttpConnection.expecting_responseHttpConnection.get_handler()HttpConnection.get_log_prefix()HttpConnection.handlersHttpConnection.headersHttpConnection.identityHttpConnection.init()HttpConnection.log_aliasHttpConnection.post_handler()HttpConnection.process_binary()HttpConnection.request()HttpConnection.request_json()
RuntimepyWebsocketConnectionRuntimepyWebsocketConnection.async_init()RuntimepyWebsocketConnection.disable_extra()RuntimepyWebsocketConnection.init()RuntimepyWebsocketConnection.poll_connection_metricsRuntimepyWebsocketConnection.poll_governorRuntimepyWebsocketConnection.send_interfacesRuntimepyWebsocketConnection.tab_sender()RuntimepyWebsocketConnection.tabsRuntimepyWebsocketConnection.ui_time
RuntimepyWebsocketJsonTcpConnectionTcpConnection.app()TcpConnection.close()TcpConnection.create_connection()TcpConnection.create_pair()TcpConnection.get_log_prefix()TcpConnection.is_sslTcpConnection.log_aliasTcpConnection.log_prefixTcpConnection.restart()TcpConnection.send_binary()TcpConnection.send_text()TcpConnection.serve()TcpConnection.uses_binary_tx_queueTcpConnection.uses_text_tx_queue
TcpConnectionFactoryTcpEchoTcpMessageTcpMessageEchoTcpNullUdpConnectionUdpConnection.close()UdpConnection.create_connection()UdpConnection.create_pair()UdpConnection.latest_rx_addressUdpConnection.log_aliasUdpConnection.process_datagram()UdpConnection.restart()UdpConnection.send_binary()UdpConnection.send_text()UdpConnection.sendto()UdpConnection.set_remote_address()UdpConnection.should_connectUdpConnection.uses_binary_tx_queueUdpConnection.uses_text_tx_queue
UdpConnectionFactoryUdpEchoUdpMessageUdpMessageEchoUdpNullWebsocketConnectionWebsocketConnectionFactoryWebsocketEchoWebsocketNull
- 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
- runtimepy.net.server.mux module
- Module contents
RuntimepyServerConnectionRuntimepyServerConnection.add_path()RuntimepyServerConnection.add_redirect_path()RuntimepyServerConnection.appsRuntimepyServerConnection.class_pathsRuntimepyServerConnection.class_redirect_pathsRuntimepyServerConnection.default_appRuntimepyServerConnection.favicon_dataRuntimepyServerConnection.get_handler()RuntimepyServerConnection.handle_command()RuntimepyServerConnection.init()RuntimepyServerConnection.json_dataRuntimepyServerConnection.log_paths()RuntimepyServerConnection.metadataRuntimepyServerConnection.pathsRuntimepyServerConnection.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
EchoMessageConnectionEchoTcpMessageConnectionEchoUdpMessageConnectionPrefixedMessageConnectionPrefixedMessageConnection.envPrefixedMessageConnection.init()PrefixedMessageConnection.loggerPrefixedMessageConnection.markdownPrefixedMessageConnection.process_binary()PrefixedMessageConnection.process_single()PrefixedMessageConnection.processorPrefixedMessageConnection.send_message()PrefixedMessageConnection.send_message_str()
StringMessageConnectionTcpPrefixedMessageConnectionTcpStringMessageConnectionUdpPrefixedMessageConnectionUdpStringMessageConnection
- runtimepy.net.tcp package
- Subpackages
- Submodules
- runtimepy.net.tcp.connection module
EchoTcpConnectionNullTcpConnectionTcpConnectionTcpConnection.app()TcpConnection.close()TcpConnection.create_connection()TcpConnection.create_pair()TcpConnection.envTcpConnection.get_log_prefix()TcpConnection.is_sslTcpConnection.log_aliasTcpConnection.log_prefixTcpConnection.loggerTcpConnection.markdownTcpConnection.remote_addressTcpConnection.restart()TcpConnection.send_binary()TcpConnection.send_text()TcpConnection.serve()TcpConnection.uses_binary_tx_queueTcpConnection.uses_text_tx_queue
- runtimepy.net.tcp.create module
- runtimepy.net.tcp.protocol module
- Module contents
EchoTcpConnectionNullTcpConnectionTcpConnectionTcpConnection.app()TcpConnection.close()TcpConnection.create_connection()TcpConnection.create_pair()TcpConnection.envTcpConnection.get_log_prefix()TcpConnection.is_sslTcpConnection.log_aliasTcpConnection.log_prefixTcpConnection.loggerTcpConnection.markdownTcpConnection.remote_addressTcpConnection.restart()TcpConnection.send_binary()TcpConnection.send_text()TcpConnection.serve()TcpConnection.uses_binary_tx_queueTcpConnection.uses_text_tx_queue
- runtimepy.net.udp package
- Subpackages
- Submodules
- runtimepy.net.udp.connection module
EchoUdpConnectionNullUdpConnectionUdpConnectionUdpConnection.close()UdpConnection.create_connection()UdpConnection.create_pair()UdpConnection.envUdpConnection.latest_rx_addressUdpConnection.log_aliasUdpConnection.loggerUdpConnection.markdownUdpConnection.process_datagram()UdpConnection.remote_addressUdpConnection.restart()UdpConnection.send_binary()UdpConnection.send_text()UdpConnection.sendto()UdpConnection.set_remote_address()UdpConnection.should_connectUdpConnection.uses_binary_tx_queueUdpConnection.uses_text_tx_queue
- runtimepy.net.udp.create module
- runtimepy.net.udp.protocol module
- runtimepy.net.udp.queue module
- Module contents
EchoUdpConnectionNullUdpConnectionQueueUdpConnectionUdpConnectionUdpConnection.close()UdpConnection.create_connection()UdpConnection.create_pair()UdpConnection.envUdpConnection.latest_rx_addressUdpConnection.log_aliasUdpConnection.loggerUdpConnection.markdownUdpConnection.process_datagram()UdpConnection.remote_addressUdpConnection.restart()UdpConnection.send_binary()UdpConnection.send_text()UdpConnection.sendto()UdpConnection.set_remote_address()UdpConnection.should_connectUdpConnection.uses_binary_tx_queueUdpConnection.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:
objectA 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,ABCA 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:
ConnectionA 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:
ConnectionA 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:
LoggerMixinA 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:
objectA mixin for adding a ‘queue’ attribute.
- class runtimepy.net.mixin.TransportMixin(transport: BaseTransport)[source]#
Bases:
objectA 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:
IntEnumSome 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:
NamedTupleSee: 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:
NamedTupleSee: 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,ABCA 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:
LoggerMixinA 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:
ConnectionA 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:
objectA 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:
NamedTupleSee: 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:
NamedTupleSee: 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:
ConnectionA 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.