Skip to main content

Cache.pull()

Remove and return the item at side of a queue, as diskcache’s pull.

Usage

Source

Cache.pull(
    prefix=None,
    default=(None, None),
    side="front",
    *,
    expire_time=False,
    tag=False,
    retry=False
)

Reads and decodes the item first, then deletes exactly that stored version, as pop does, so an item this process can’t read stays queued for one that can (D-056): a pickled item on a pickle=False handle raises UnsafeValueError, and a newer deploy’s value raises, or with on_decode_error='miss' returns default. An item no build could read is removed, then raised as CorruptValueError, or under 'miss' reported while the pull goes on to the next. A puller that loses the head to others reads the new one; one that keeps losing until timeout raises Timeout, having taken nothing. Expired items are passed over. Inside a transact() block it joins the transaction, and a rollback puts the item back.

Parameters

prefix: str | None = None

The queue’s name, or None for the int queue.

default: Any = (None, None)

Returned when the queue is empty (default (None, None)).

side: Literal["front", "back"] = "front"

'front' (the default) or 'back'.

expire_time: bool = False

Also return the item’s expiry time.

tag: bool = False

Also return the item’s tag.

retry: bool = False
As for get().

Returns

Any

(key, value), or with expire_time and tag ((key, value), expire_time, tag) and the

pairs, as get()’s tuples; default, widened to match, when empty.

Examples

key, job = jobs.pull(prefix='transcode')
if key is not None:
    transcode(job)