Skip to main content

Queue-like items: iterable queues, channels, etc.

Latest release 20221207: PushQueue: modernise the MutiOpenMixin startup_shutdown, do both open and close of self.outQ.

Class Channel

A zero-storage data passage. Unlike a Queue, put(item) blocks waiting for the matching get().

Method Channel.__init__(self): pylint: disable=consider-using-with

Function IterablePriorityQueue(capacity=0, name=None)

Factory to create an iterable PriorityQueue.

Function IterableQueue(capacity=0, name=None)

Factory to create an iterable Queue.

Class ListQueue

A simple iterable queue based on a list.

Method ListQueue.__init__(self, queued=None): Initialise the queue. queued is an optional iterable of initial items for the queue.

NullQ = <NullQueue:NullQ blocking=False>

A queue-like object that discards its inputs. Calls to .get() raise Queue_Empty.

Class NullQueue(cs.resources.MultiOpenMixin, cs.context.ContextManagerMixin)

A queue-like object that discards its inputs. Calls to .get() raise Queue_Empty.

Method NullQueue.__init__(self, blocking=False, name=None): Initialise the NullQueue.

Parameters:

  • blocking: optional; if true, calls to .get() block until .shutdown(); default: False.
  • name: optional name for this NullQueue.

Class PushQueue(cs.resources.MultiOpenMixin, cs.context.ContextManagerMixin)

A puttable object which looks like an iterable Queue.

In this base class, calling .put(item) calls functor supplied at initialisation to trigger a function on data arrival whose iterable of results are put onto the output queue.

As an example, the cs.pipeline.Pipeline class uses subclasses of PushQueue for each pipeline stage, overriding the .put(item) method to mediate the call of functor through cs.later.Later as resource controlled concurrency.

Method PushQueue.__init__(self, name, functor, outQ): Initialise the PushQueue with the callable functor and the output queue outQ.

Parameters:

  • functor is a one-to-many function which accepts a single item of input and returns an iterable of outputs; it may be a generator. These outputs are passed to outQ.put individually as received.
  • outQ is a MultiOpenMixin which accepts via its .put() method.

Class QueueIterator(cs.resources.MultiOpenMixin, cs.context.ContextManagerMixin)

A QueueIterator is a wrapper for a Queue (or ducktype) which presents an iterator interface to collect items. It does not offer the .get or .get_nowait methods.

Class TimerQueue

Class to run a lot of "in the future" jobs without using a bazillion Timer threads.

Release Log

Release 20221207: PushQueue: modernise the MutiOpenMixin startup_shutdown, do both open and close of self.outQ.

Release 20220918: Expose formerly private _QueueIterator as QueueIterator, use a per-queue sentinel from cs.obj.Sentinel.

Release 20220805: ListQueue: add "append" synonym for "put" in keeping with the list-ish flavour.

Release 20220605: ListQueue: extend/prepend: reject str explicitly - although iterable, it is almost never what is intended.

Release 20220317: Add missed import.

Release 20220313: New ListQueue.prepend(items[,offset=0]) method.

Release 20211116: ListQueue: new insert() method.

Release 20210924: Channel: make a Channel iterable.

Release 20210913: New ListQueue simple iterable queue based on a list with list-like .append and .extend.

Release 20201025: Drop obsolete call to MultiOpenMixin.init.

Release 20200718: _QueueIterator: set finalise_later via new MultiOpenMixin property, required by recent MultiOpenMixin change.

Release 20200521: IterableQueue,IterablePriorityQueue: simplify wrappers, bypasses weird bug from overengineering these.

Release 20191007:

  • PushQueue: improve str.
  • Clean lint, drop cs.obj dependency.

Release 20190812: _QueueIterator: do MultiOpenMixin.init so that str is functional.

Release 20181022: Bugfix Channel, drasticly simplify PushQueue, other minor changes.

Release 20160828:

  • Use "install_requires" instead of "requires" in DISTINFO.
  • TimerQueue.add: support optional *a and **kw arguments for func.
  • Many bugfixes and internal changes.

Release 20150115: More PyPI metadata fixups.

Release 20150111: Initial PyPI release.

Release files for cs-queues 20221207

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cs-queues 20221207
File Size Uploaded
cs.queues-20221207.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cs-queues 20221207
File Interpreter ABI Platform
cs.queues-20221207-py3-none-any.whl Python 3 none any Details

Total release size: 17.6 kB

Release files / cs.queues-20221207.tar.gz

Download URL cs.queues-20221207.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1519768f255ceca70edfce071ce5248de755d8689fc0a51953ed5d872641631c
BLAKE2b-256 checksum
How to use checksums
d8b9ee1a5048c2efecc435bca25606fca5521cd2f447d7c1277c5e1eb2556d94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / cs.queues-20221207-py3-none-any.whl

Download URL cs.queues-20221207-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a981ab50819efb1998e2d998a8d3e96888e2bbf9acf6c33da8f72bdef977647
BLAKE2b-256 checksum
How to use checksums
d4a6470ef988ba2c3c030645194d6c8ac4c12b666096ca4405ec481ebd44282b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page