logging_listeners¶
- class pyrosetta.distributed.cluster.logging_listeners.LogRecordRequestHandler(request, client_address, server)¶
Bases:
StreamRequestHandler
Handler for a streaming logging request modified from logging cookbook recipe: https://docs.python.org/3/howto/logging-cookbook.html#sending-and-receiving-logging-events-across-a-network
- unPickle(msg: bytes) Dict[str, Any] ¶
Log record decompress method override using MessagePack and hash-based message authentication codes (HMAC).
- __init__(request, client_address, server)¶
- disable_nagle_algorithm = False¶
- finish()¶
- rbufsize = -1¶
- timeout = None¶
- wbufsize = 0¶
- class pyrosetta.distributed.cluster.logging_listeners.SocketListener(logging_address: str, logging_file: str, logging_level: str, timeout: Union[float, int], ignore_errors: bool)¶
Bases:
ThreadingTCPServer
TCP socket-based logging receiver modified from logging cookbook recipe: https://docs.python.org/3/howto/logging-cookbook.html#sending-and-receiving-logging-events-across-a-network
- allow_reuse_address = True¶
- __init__(logging_address: str, logging_file: str, logging_level: str, timeout: Union[float, int], ignore_errors: bool) None ¶
Constructor. May be extended, do not override.
- timeout = None¶
- setup_handler(logging_file: str, logging_level: str) FileHandler ¶
Setup logging file handler for logging socket listener.
- _handle_request_noblock()¶
Handle one request, without blocking.
I assume that selector.select() has returned that the socket is readable before this function was called, so there should be no risk of blocking in get_request().
- _threads = <socketserver._NoThreads object>¶
- address_family = 2¶
- allow_reuse_port = False¶
- block_on_close = True¶
- close_request(request)¶
Called to clean up an individual request.
- daemon_threads = False¶
- fileno()¶
Return socket file number.
Interface required by selector.
- finish_request(request, client_address)¶
Finish one request by instantiating RequestHandlerClass.
- get_request()¶
Get the request and client address from the socket.
May be overridden.
- handle_error(request, client_address)¶
Handle an error gracefully. May be overridden.
The default is to print a traceback and continue.
- handle_request()¶
Handle one request, possibly blocking.
Respects self.timeout.
- handle_timeout()¶
Called if no new request arrives within self.timeout.
Overridden by ForkingMixIn.
- process_request(request, client_address)¶
Start a new thread to process the request.
- process_request_thread(request, client_address)¶
Same as in BaseServer but as a thread.
In addition, exception handling is done here.
- request_queue_size = 5¶
- serve_forever(poll_interval=0.5)¶
Handle one request at a time until shutdown.
Polls for shutdown every poll_interval seconds. Ignores self.timeout. If you need to do periodic tasks, do them in another thread.
- server_activate()¶
Called by constructor to activate the server.
May be overridden.
- server_bind()¶
Called by constructor to bind the socket.
May be overridden.
- server_close()¶
Called to clean-up the server.
May be overridden.
- service_actions()¶
Called by the serve_forever() loop.
May be overridden by a subclass / Mixin to implement any code that needs to be run during the loop.
- shutdown()¶
Stops the serve_forever loop.
Blocks until the loop has finished. This must be called while serve_forever() is running in another thread, or it will deadlock.
- shutdown_request(request)¶
Called to shutdown and close an individual request.
- socket_type = 1¶
- verify_request(request, client_address)¶
Verify the request. May be overridden.
Return True if we should proceed with this request.