Skip to main content

some Queue subclasses and ducktypes

Project description

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

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

Class Channel

A zero-storage data passage. Unlike a Queue(1), put() 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 TimerQueue

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

Release Log

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cs.queues-20220605.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cs.queues-20220605-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file cs.queues-20220605.tar.gz.

File metadata

  • Download URL: cs.queues-20220605.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.1 readme-renderer/30.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.3.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.9.13

File hashes

Hashes for cs.queues-20220605.tar.gz
Algorithm Hash digest
SHA256 9c0d337a0bdb8a76cdc7789df41c69bdd66116c97e8b8e9066e4fbd4e820c6a7
MD5 5906ca1fc52182b4d90ffe20c0934c46
BLAKE2b-256 28a0fe63daca7c849807e440ccbe5e48f9ddeb8de58fbaa5e2ee5cfa2982636b

See more details on using hashes here.

File details

Details for the file cs.queues-20220605-py3-none-any.whl.

File metadata

  • Download URL: cs.queues-20220605-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.1 readme-renderer/30.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.3.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.9.13

File hashes

Hashes for cs.queues-20220605-py3-none-any.whl
Algorithm Hash digest
SHA256 82b4e291a709a36949f26e80ed1da607c05b2470fda855ab3eeebfa65b6a00ed
MD5 a122b12d65155cb9b9b1c4276d9039ef
BLAKE2b-256 83b58b4c66b70ad23b827f97cfe9471eff2c1d94bae109db3f6bb060d15ab021

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page