aioworkerpool: async worker pool

Master/Worker pool for asyncio (PEP 3156).

Features

  • Uses fork() to reuse python interpreter

  • Supports proxying of stdout/stderr from workers to files

  • Provides multiprocess-aware logging transport

  • Supports file descriptor preserving

  • May run as UNIX daemon

Library installation

$ pip install aioworkerpool

Getting started

Example (see quickstart.py)

import asyncio
import os

from aioworkerpool import master, worker


# Add some useful code
class WorkerHandler(worker.WorkerBase):

    async def main(self):
        while self.is_running():
            print("%s: I am here!" % os.getpid())
            await asyncio.sleep(1)


# Setup aioworkerpool.master.Supervisor instance
s = master.Supervisor(WorkerHandler)

# Run worker pool
s.main()

Running examples:

$ cd aioworkerpool
$ python -m examples.quickstart

Source code

Dependencies

  • POSIX operation system

  • Python 3.5+ (basically, asyncio and async/await syntax)

  • python-daemon

  • tblib

Current development status

Library is under active development so API may change dramatically.

Indices and tables