What is Janus and when should I use it?
masterJanus is a mixed synchronous-asynchronous queue designed specifically for communication between classic synchronous (threaded) code and asynchronous (asyncio) code.
It provides a single queue object with two distinct interfaces:
- A synchronous interface (
sync_q) that is fully compatible with Python's standardqueue.Queue. - An asynchronous interface (
async_q) that follows theasyncio.Queuedesign.
Important Performance Note: Janus is optimized for cross-paradigm communication. If your application only uses synchronous code or only uses asynchronous code, you should use the standard queue or asyncio.Queue modules instead, as using Janus in those cases can result in significant performance slowdowns.