Logger for multiprocessing applications
Project description
multiprocessing-logging
When using the multiprocessing
module, logging becomes less useful since
sub-processes should log to individual files/streams or there's the risk of
records becoming garbled.
This simple module implements a Handler
that when set on the root
Logger
will handle tunneling the records to the main process so that
they are handled correctly.
It's currently tested in Linux and Python 2.7 & 3.5+.
Pypy3 hangs on the tests so I don't recommend using it.
Pypy appears to be working, recently.
Only works on POSIX systems and only Linux is supported. It does not work on Windows.
Origin
This library was taken verbatim from a StackOverflow post and extracted into a module so that I wouldn't have to copy the code in every project.
Later, several improvements have been contributed.
Usage
Before you start logging but after you configure the logging framework (maybe with logging.basicConfig(...)
), do the following:
import multiprocessing_logging
multiprocessing_logging.install_mp_handler()
and that's it.
With multiprocessing.Pool
When using a Pool, make sure install_mp_handler
is called before the Pool is instantiated, for example:
import logging
from multiprocessing import Pool
from multiprocessing_logging import install_mp_handler
logging.basicConfig(...)
install_mp_handler()
pool = Pool(...)
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 Distributions
Built Distribution
File details
Details for the file multiprocessing_logging-0.3.1-py2.py3-none-any.whl
.
File metadata
- Download URL: multiprocessing_logging-0.3.1-py2.py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d3eb0f1f859b7ba6250a029726f77a7701999deda939595122d8748751de2e3 |
|
MD5 | 29f46d490af0756ed9a4d0200c0458af |
|
BLAKE2b-256 | 2a3f9a123bb0f98b37956651dbc86d8a8821b6267ab96603c8a8b47d333e7f03 |