{"id":27674,"library":"culsans","title":"Culsans - Thread-safe async-aware queue for Python","description":"Culsans is a thread-safe async-aware queue for Python, providing a drop-in replacement for asyncio.Queue and janus.Queue with improved cancellation handling, phase-fair priority, and reentrant readers-writer lock (RWLock). It supports Python >=3.8 and is built on top of the aiologic library. Current version is 0.11.0, with a release cadence of approximately monthly updates.","status":"active","version":"0.11.0","language":"python","source_language":"en","source_url":"https://github.com/x42005e1f/culsans","tags":["async","queue","thread-safe","aiologic","concurrency"],"install":[{"cmd":"pip install culsans","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for lock-free async primitives","package":"aiologic","optional":false}],"imports":[{"note":"Queue is directly exposed at the package level, not in a submodule.","wrong":"from culsans.queue import Queue","symbol":"Queue","correct":"from culsans import Queue"},{"note":"Exception classes are exported from the top-level package.","wrong":"from culsans.exceptions import QueueShutDown","symbol":"QueueShutDown","correct":"from culsans import QueueShutDown"},{"note":"Introduced in 0.11.0; ensure version >= 0.11.0.","wrong":"","symbol":"Grouper","correct":"from culsans import Grouper"},{"note":"Introduced in 0.11.0; ensure version >= 0.11.0.","wrong":"","symbol":"RWLock","correct":"from culsans import RWLock"}],"quickstart":{"code":"import asyncio\nfrom culsans import Queue\n\nasync def producer(queue):\n    for i in range(5):\n        await queue.put(i)\n        print(f'Produced {i}')\n\nasync def consumer(queue):\n    while True:\n        item = await queue.get()\n        if item is None:\n            break\n        print(f'Consumed {item}')\n        queue.task_done()\n\nasync def main():\n    queue = Queue()\n    prod = asyncio.create_task(producer(queue))\n    cons = asyncio.create_task(consumer(queue))\n    await prod\n    await queue.put(None)  # sentinel\n    await cons\n\nasyncio.run(main())","lang":"python","description":"Basic async producer-consumer example using Culsans Queue."},"warnings":[{"fix":"If you rely on checkpoint timing, review your code for any assumptions about when checkpoints are called. Consider using synchronous methods if context switches are costly.","message":"In version 0.9.0, checkpoint functions are now called before queue operations instead of after. This may increase the number of explicit context switches, affecting performance or behavior in tight loops.","severity":"breaking","affected_versions":">=0.9.0"},{"fix":"Upgrade to Python 3.9+ to ensure compatibility with future releases.","message":"Python 3.8 support was added in 0.8.0, but Python 3.8 is itself end-of-life. Future versions may drop Python 3.8 support.","severity":"deprecated","affected_versions":">=0.8.0, <0.12.0"},{"fix":"Use 'from culsans import QueueShutDown' to ensure compatibility across Python versions; avoid importing from the stdlib's asyncio.queues.","message":"QueueShutDown is raised on various operations after close() or shutdown(), consistent with Python 3.13's queue shutdown. However, on Python <3.13, the exception is backported and may cause name conflicts with type checkers.","severity":"gotcha","affected_versions":"<3.13"},{"fix":"Use MixedQueue only for type annotations; use Queue, LifoQueue, PriorityQueue, etc. for instantiation.","message":"MixedQueue is a protocol, not a concrete class. Do not instantiate MixedQueue directly.","severity":"gotcha","affected_versions":">=0.8.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use 'from culsans import Queue'","cause":"Queue is not in a submodule; it is directly exported from the top-level package.","error":"from culsans.queue import Queue\nModuleNotFoundError: No module named 'culsans.queue'"},{"fix":"Ensure you have installed culsans >=0.7.0. Use 'from culsans import LifoQueue' if you need LIFO behavior.","cause":"LifoQueue was removed in version 0.7.0 in favor of general Queue with an optional 'maxsize' parameter and 'type' argument? Actually, LifoQueue is still present, but this error may occur if using an old version or incorrect import path.","error":"AttributeError: module 'culsans' has no attribute 'LifoQueue'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}