Non-blocking consumption of multi-process log messages
Project description
ipclog
Supports Python multi-process non-blocking log processing to prevent important processes from being blocked due to log processing.
Especially when there are many and important processes, log messages need to be processed at the same time, and these processing processes are time-consuming and may block important processes.
Must Read Before use
https://man7.org/linux/man-pages/man7/pipe.7.html
Pipe capacity, A pipe has a limited capacity.
PIPE_BUF (because of it, Configure the size of IPClient.ATOMIC_MAX according to your own server conditions.
If you really don't know how much to set, you can determine it through experiments which prepared script tests.test_logger.test_ipc_multi_big_log)
How To
from ipclog.logger import init_logger
from ipclog.ipc_server import IPCServer
def init_log():
il = init_logger(
filters=lambda record: record.get("msg"), add_fields={"field0": 0}
)
return {"ctx": 1, "logger": il}
def exec_log(ll, ctx):
ctx["logger"].info(ll, extra=json.loads(ll))
with IPCServer("./tmp.fifo", inits=init_log, execute=exec_log, nonblock=True, cache_len=100) as ipc:
ll = init_logger(ipc_client=ipc)
for i in range(100):
ll.info(f"ipc->{i}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ipclog-0.0.1.tar.gz.
File metadata
- Download URL: ipclog-0.0.1.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cbd5dd5b06b7fd9fe5b566ecd973012b5488e629f83740b59bbe077585b18cf
|
|
| MD5 |
a2a5330224ce5c86e60661fa72ac283a
|
|
| BLAKE2b-256 |
d505f3ee0f0da2eb110a0a0ca14b762c23a3d7457a5810e26e71c63652959ddf
|
File details
Details for the file ipclog-0.0.1-py3-none-any.whl.
File metadata
- Download URL: ipclog-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09d043988bc42c5999d4fdfd0d9ef7aa254773aa9d275d24a6f0b1aee717f47d
|
|
| MD5 |
84caa4bf2a1b70fe0f5153412780eea4
|
|
| BLAKE2b-256 |
23a3fc3afa66dd6603667bd43da8be8b6879ead8053692856e18e2b850a4f5f2
|