Skip to main content

Multiprocess logbook logging for asyncio

Project description

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.


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, \
from logbook import Logger, StderrHandler

async def mainTask(eventLoop):
    # The parent process logger can be set up as normal.
    log = Logger()

    rx, tx = aiopipe()
    sub = AioPipeSubscriber(await, log)

    with closing(sub):
        subTask = eventLoop.create_task(

        with tx.send() as tx:
            proc = Process(target=childProc, args=(tx,))
            proc.start()"hello from parent process")

        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

    with closing(handler):"hello from child process")

eventLoop = asyncio.get_event_loop()


This package requires Python >= 3.5.0 and can be installed with pip:

pip install logbook_aiopipe

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for logbook-aiopipe, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size logbook_aiopipe-0.2.0-py3-none-any.whl (3.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size logbook_aiopipe-0.2.0.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page