📜  python多处理日志记录-任何代码示例

📅  最后修改于: 2022-03-11 14:57:16.780000             🧑  作者: Mango

代码示例1
The only way to deal with this non-intrusively is to:

Spawn each worker process such that its log goes to a different file descriptor (to disk or to pipe.) Ideally, all log entries should be timestamped.
Your controller process can then do one of the following:
If using disk files: Coalesce the log files at the end of the run, sorted by timestamp
If using pipes (recommended): Coalesce log entries on-the-fly from all pipes, into a central log file. (E.g., Periodically select from the pipes' file descriptors, perform merge-sort on the available log entries, and flush to centralized log. Repeat.)