logbook_aiopipe -- Multiprocess logbook logging for asyncio
This package provides a handler and subscriber for multiprocess
logbook logging that runs on the
asyncio event loop. It uses
aiopipe to transfer log messages from the child
process to the parent process.
Example
The following example shows a typical application of multiprocess logging. It results in
two log messages, hello from parent process and hello from child process, being
printed in some order.
from contextlib import closing
from multiprocessing import Process
import asyncio
from aiopipe import aiopipe
from logbook_aiopipe import AioPipeSubscriber, \
AioPipeHandler
from logbook import Logger, StderrHandler
async def mainTask(eventLoop):
# The parent process logger can be set up as normal.
log = Logger()
log.handlers.append(StderrHandler())
rx, tx = aiopipe()
sub = AioPipeSubscriber(await rx.open(eventLoop), log)
with closing(sub):
subTask = eventLoop.create_task(sub.run())
with tx.send() as tx:
proc = Process(target=childProc, args=(tx,))
proc.start()
log.info("hello from parent process")
proc.join()
await subTask
def childProc(tx):
eventLoop = asyncio.new_event_loop()
eventLoop.run_until_complete(childTask(eventLoop, tx))
async def childTask(eventLoop, tx):
log = Logger()
# The child process should use only `AioPipeHandler` as
# its handler.
handler = AioPipeHandler(await tx.open(eventLoop))
log.handlers.append(handler)
with closing(handler):
log.info("hello from child process")
eventLoop = asyncio.get_event_loop()
eventLoop.run_until_complete(mainTask(eventLoop))
Installation
This package requires Python >= 3.5.0 and can be installed with pip:
pip install logbook_aiopipe
Metadata
Release files for logbook-aiopipe 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| logbook_aiopipe-0.2.0.tar.gz | 3.0 kB | Without provenance | Details for logbook_aiopipe-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| logbook_aiopipe-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for logbook_aiopipe-0.2.0-py3-none-any.whl |
Total release size: 6.8 kB
Release files / logbook_aiopipe-0.2.0.tar.gz
| Download URL | logbook_aiopipe-0.2.0.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c21e421035eadbd572afb33042cd7cbfe9dfe865ce4b9c13d2e4c9375e7cae7f
|
|
BLAKE2b-256 checksum How to use checksums |
bc205d7cef1dc87db682dbbc6c680fead57697a1622dd611640c94fe01ca451c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.6
|
Release files / logbook_aiopipe-0.2.0-py3-none-any.whl
| Download URL | logbook_aiopipe-0.2.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
899e9e9619a748b3f5fa2abb64e47749cd5d4c2944b65688cd12118e5fe59520
|
|
BLAKE2b-256 checksum How to use checksums |
54106e37a88d467257c8f5fc413c6e70dbece7d7451e0af1c07f371295baabaf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.6
|
Security for logbook-aiopipe 0.2.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.