skillfed

janus

Mixed sync-async queue to interoperate between asyncio tasks and classic threads

janus v2.0.0 6.7M downloads/30d#1,868 on PyPI964
Permissive license Apache 2 Active released

What it is and what it does

Janus is a queue implementation that bridges synchronous (threaded) and asynchronous (asyncio) code by exposing the same queue object through two separate interfaces: sync_q for classic Python threads and async_q for asyncio tasks. It implements Queue, LifoQueue, and PriorityQueue variants, each compatible with their standard library counterparts on the sync side and asyncio queue design on the async side.

The library is built on thread-safe primitives and is production-stable, actively maintained to support current Python versions. It's designed specifically for the use case of passing data between a threaded executor and asyncio code running in the same process. The main constraint is that you must explicitly close the queue with aclose() when done, and it performs best only when actually bridging sync and async code—for purely synchronous or purely asynchronous scenarios, the standard library queues are faster.

Use it for:

  • Pass work items from a thread pool to asyncio tasks without manual synchronization.
  • Collect results from blocking I/O operations in threads and consume them asynchronously.
  • Integrate legacy synchronous libraries into an asyncio-based application.
  • Coordinate between a background worker thread and an asyncio event loop.
  • Implement a producer-consumer pattern where one side is threaded and the other is async.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a thread-safe queue with both synchronous and asynchronous interfaces for passing data between classic threaded code and asyncio tasks.

Yes, if you need to communicate between threaded and asyncio code in the same process. The library is stable, well-maintained, has no external dependencies, and solves a real coordination problem. Install it only if you actually have both sync and async code to bridge; for purely sync or purely async scenarios, use the standard library queues instead.

Install

janus on PyPI

pip

pip install janus

uv

uv add janus

poetry

poetry add janus

Installing janus

Before you install

Low friction: pure Python wheel with no runtime dependencies. Actively maintained with recent commits and stable production status.

License in practice

Apache 2 permissive license allows commercial and private use with minimal restrictions.

Quickstart

import asyncio
import janus

async def main():
    queue = janus.Queue()
    loop = asyncio.get_running_loop()
    loop.run_in_executor(None, lambda: queue.sync_q.put(None))
    val = await queue.async_q.get()
    await queue.aclose()

asyncio.run(main())

Must call aclose() when done to properly clean up internal tasks; requires Python 3.9 or later.

Verify before relying

  • Whether the performance penalty for sync-only or async-only use cases is acceptable for your workload.
  • Whether culsans (mentioned as an experimental alternative) offers the features or performance your application needs.

Package facts

License Apache 2 (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 609 days since the last release
Last repo commit
First released
Downloads 6,702,225/month — #1,868 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: janus-2.0.0-py3-none-any.whl

Keywords: janus, queue, asyncio

Development Status :: 5 - Production/StableFramework :: AsyncIOIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries

Tags

sync async queuethread asyncio communicationmixed sync-async queueasyncio thread bridgequeue between threads and tasks
asynciothreadingqueue

More Libraries packages