janus
Mixed sync-async queue to interoperate between asyncio tasks and classic threads
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 janusuv
uv add januspoetry
poetry add janusInstalling 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
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
aiochannelProvides asyncio-compatible channels (closable…
permissive · top 15,000 on PyPI
culsansProvides a dual-interface queue (sync and…
permissive · top 5,000 on PyPI
synchronicityWraps async functions, generators, and classes…
permissive · top 1,000 on PyPI
threadedProvides decorators to wrap functions for…
permissive · top 15,000 on PyPI
asyncerAsyncer provides utility functions for working…
permissive · top 5,000 on PyPI
arqarq provides a job queue system for Python that…
permissive · top 5,000 on PyPI
nexus-rpcNexus Python SDK provides a framework for…
permissive · top 1,000 on PyPI
aiologicaiologic provides thread-aware and async-aware…
permissive · top 5,000 on PyPI
persist-queueProvides thread-safe, disk-based queue…
permissive · top 15,000 on PyPI
powerbot-clientPowerBot client library for synchronous…
unclear · top 15,000 on PyPI