Skip to main content

multiprocessing-logging

Run Status Coverage Badge Supported Python versions License

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.

It was tested by users and reported to work on Windows with Python 3.5 and 3.6.

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

loggig.basicConfig(...)
install_mp_handler()
pool = Pool(...)

Metadata

Release files for multiprocessing-logging 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for multiprocessing-logging 0.3.0
File Interpreter ABI Platform Actions
multiprocessing_logging-0.3.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for multiprocessing_logging-0.3.0-py2.py3-none-any.whl

Release files / multiprocessing_logging-0.3.0-py2.py3-none-any.whl

Download URL multiprocessing_logging-0.3.0-py2.py3-none-any.whl
Size 7.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
76790aebe751a40c8bb63175e204db73b7a78b3d4e0b73a96b6d02a11b2630f5
BLAKE2b-256 checksum
How to use checksums
7630251cdbbb71b9abe4164dfe70a1341cde21098918c50eecd882c0d32f65ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Security for multiprocessing-logging 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page