meld.util

Functions

configure_logging_and_launch_listener(host, …)

in_temp_dir()

Context manager to run in temporary directory

log_timing(dest_logger)

Classes

HostNameContextFilter(hostid)

Filter class that adds hostid information to logging records.

LogRecordSocketReceiver(host, abort_queue, …)

Simple TCP socket-based logging receiver.

LogRecordStreamHandler(request, …)

Handler for a streaming logging request.

class meld.util.HostNameContextFilter(hostid)[source]

Filter class that adds hostid information to logging records.

filter(record)[source]

Determine if the specified record is to be logged.

Is the specified record to be logged? Returns 0 for no, nonzero for yes. If deemed appropriate, the record may be modified in-place.

class meld.util.LogRecordSocketReceiver(host, abort_queue, socket_queue, handler=<class 'meld.util.LogRecordStreamHandler'>)[source]

Simple TCP socket-based logging receiver.

The configure_logging_and_launch_listener function should be launched in another process. The socket number can be retrieved from socket_queue and the logger can be told to abort through the abort_queue.

close_request(request)

Called to clean up an individual request.

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.

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.

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.

verify_request(request, client_address)

Verify the request. May be overridden.

Return True if we should proceed with this request.

class meld.util.LogRecordStreamHandler(request, client_address, server)[source]

Handler for a streaming logging request.

This basically logs the record using whatever logging policy is configured locally.

handle()[source]

Handle multiple requests - each expected to be a 4-byte length, followed by the LogRecord in pickle format. Logs the record according to whatever policy is configured locally.

meld.util.in_temp_dir()[source]

Context manager to run in temporary directory