MultitaskHandler¶
- class sofia_redux.toolkit.utilities.multiprocessing.MultitaskHandler[source]¶
Bases:
Handler
A log handler for multitask.
Initialize a multitask log Handler.
The multitask log handler is designed to separately store log messages for each process or thread in order to retrieve those messages later for standard logging. This allows log messages to be output in order for each process.
Methods Summary
emit
(record)Emit a log record.
Re-order the records in a sensible order.
Methods Documentation
- emit(record)[source]¶
Emit a log record.
Stores the record in the lookup dictionary for the given process/thread. Each message is stored in the received order for later retrieval once whatever multiprocessing job is complete.
- Parameters:
- recordlogging.LogRecord
The record to emit.
- Returns:
- None
- reorder_records()[source]¶
Re-order the records in a sensible order.
The records are sorted by process and then thread in chronological order. I.e., records are grouped by processes, starting with the first process that appears in the logs and then within that process group, a similar grouping is performed for each child thread. Each process-thread grouping will contain a list of log records in the order that they where emitted.
Note that each record is a tuple of the form (time, process, thread, log_record).
- Returns:
- None