Package: cs.queues
Queue-like items: iterable queues, channels, etc.Latest release 20240211:
ListQueue: new unique parameter which uses cs.seq.unrepeated in iteration.ClassChannelA zero-storage data passage.
Unlike aQueue,put(item)blocks waiting for the matchingget().MethodChannel.__init__(self):
pylint: disable=consider-using-withFunctionIterablePriorityQueue(capacity=0, name=None)Factory to create an iterablePriorityQueue.FunctionIterableQueue(capacity=0, name=None)Factory to create an iterable queue.
Note that the returned queue is already open
and needs a close.ClassListQueueA simple iterable queue based on alist.MethodListQueue.__init__(self, queued=None, *, unique=None):
Initialise the queue.Parameters:queuedis an optional iterable of initial items for the queueunique: optional signature function, defaultNoneTheuniqueparameter provides iteration via thecs.seq.unrepeatediterator filter which yields only items
not seen earlier in the iteration.
IfuniqueisNoneorFalseiteration iterates
over the queue items directly.
IfuniqueisTrue, iteration uses the default mode
where items are compared for equality.
Otherwiseuniquemay be a callable which produces a
value to use to detect repetitions, used as thecs.seq.unrepeatedsignatureparameter.Example:>>> items = [1, 2, 3, 1, 2, 5]
>>> list(ListQueue(items))
[1, 2, 3, 1, 2, 5]
>>> list(ListQueue(items, unique=True))
[1, 2, 3, 5]NullQ = <NullQueue:NullQ blocking=False>A queue-like object that discards its inputs.
Calls to.get()raiseQueue_Empty.ClassNullQueue(cs.resources.MultiOpenMixin, cs.context.ContextManagerMixin)A queue-like object that discards its inputs.
Calls to.get()raiseQueue_Empty.MethodNullQueue.__init__(self, blocking=False, name=None):
Initialise theNullQueue.Parameters:blocking: optional; if true, calls to.get()block until.shutdown(); default:False.name: optional name for thisNullQueue.ClassPushQueue(cs.resources.MultiOpenMixin, cs.context.ContextManagerMixin)A puttable object which looks like an iterableQueue.In this base class,
calling.put(item)callsfunctorsupplied at initialisation
to trigger a function on data arrival
whose iterable of results are put onto the output queue.As an example, thecs.pipeline.Pipelineclass
uses subclasses ofPushQueuefor each pipeline stage,
overriding the.put(item)method
to mediate the call offunctorthroughcs.later.Lateras resource controlled concurrency.MethodPushQueue.__init__(self, name, functor, outQ):
Initialise the PushQueue with the callablefunctorand the output queueoutQ.Parameters:functoris 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 tooutQ.putindividually as
received.outQis aMultiOpenMixinwhich accepts via its.put()method.ClassQueueIterator(cs.resources.MultiOpenMixin, cs.context.ContextManagerMixin)AQueueIteratoris a wrapper for aQueue(or ducktype) which
presents an iterator interface to collect items.
It does not offer the.getor.get_nowaitmethods.ClassTimerQueueClass to run a lot of "in the future" jobs without using a bazillion
Timer threads.Release LogRelease 20240211:
ListQueue: new unique parameter which uses cs.seq.unrepeated in iteration.Release 20231129:ListQueue: addlen,str,repr.QueueIterator: use a mutex around the item counting.Release 20230331:QueueIterator.startup_shutdown: try/finally for the terminating _put(self.sentinel).QueueIterator.str: show the underlying queue.QueueIterator: drop call to self.finalise(), no longer available or needed.Release 20221228:
Minor doc update.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: improvestr.Clean lint, drop cs.obj dependency.Release 20190812:
_QueueIterator: do MultiOpenMixin.initso thatstris 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.