docket API reference
96 public APIs from docket (chrisguidry/docket) — 26 classes, 24 functions, 46 methods. Signatures extracted by static analysis of the actual source.
Repository: chrisguidry/docket
| Kind | Count |
|---|---|
| Classes | 26 |
| Functions | 24 |
| Methods | 46 |
API list
func
chaos.driver.package_exists_on_pypi(package:str, version:str) -> boolCheck if a package version exists on PyPI.
func
chaos.redis.get_free_port() -> intFind an available TCP port.
func
chaos.redis.run_redis(version:str) -> AsyncGenerator[tuple[str, Container], None]Start a Redis Docker container and yield (url, container).
func
chaos.signals.main() -> NoneRun signal handling tests for both SIGTERM and SIGINT.
func
chaos.signals.run_signal_test(sig:signal.Signals, redis_url:str, num_workers:int=2, tasks_per_worker:int=2, task_duration:float=5.0) -> tuple[bool, str]Run a single signal handling test.
func
chaos.signals.spawn_worker(docket_name:str, redis_url:str, channel:str, concurrency:int=2) -> ProcessSpawn a worker subprocess.
func
chaos.signals.verify_tasks_completed(docket:Docket, task_keys:list[str]) -> tuple[bool, list[str]]Verify all tasks completed successfully via Redis state.
class
src.docket._execution_progress.ExecutionProgressManages user-reported progress for a task execution.
method
src.docket._execution_progress.ExecutionProgress.increment(amount:int=1) -> NoneAtomically increment the current progress value.
method
src.docket._execution_progress.ExecutionProgress.set_message(message:str | None) -> NoneUpdate the progress status message.
method
src.docket._execution_progress.ExecutionProgress.set_total(total:int) -> NoneSet the total/target value for progress tracking.
method
src.docket._execution_progress.ExecutionProgress.subscribe(*ready:asyncio.Event | None=None) -> AsyncGenerator[ProgressEvent, None]Subscribe to progress updates for this task.
class
src.docket._prometheus_exporter.PrometheusMetricReaderPrometheus metric exporter for OpenTelemetry.
func
src.docket._prometheus_exporter.map_unit(unit:str) -> strMap unit to Prometheus metric name conventions.
func
src.docket._prometheus_exporter.sanitize_attribute(key:str) -> strSanitize attribute key according to Prometheus rules.
func
src.docket._prometheus_exporter.sanitize_full_name(name:str) -> strSanitize metric name including leading digits.
class
src.docket._redis.AsyncCloseableProtocol for objects with an async aclose() method.
class
src.docket._redis.PubSubClientProtocol capturing the pub/sub interface that docket uses.
class
src.docket._redis.RedisStreamPendingMessageOne entry returned by XPENDING ...
func
src.docket._redis.close_resource(resource:AsyncCloseable, name:str) -> NoneClose a resource with error handling.
func
src.docket._redis.get_memory_server(url:str) -> MemoryRedisClient | NoneGet the cached BurnerRedis instance for a URL, if any.
func
src.docket._redis_sentinel.is_sentinel_url(url:str) -> boolWhether ``url`` is a redis+sentinel:// or rediss+sentinel:// URL.
func
src.docket._redis_sentinel.parse_sentinel_url(url:str) -> SentinelConfigurationParse a redis+sentinel:// or rediss+sentinel:// URL.
func
src.docket._redis_sentinel.urlparse_multihost(url:str) -> ParseResulturlparse a sentinel URL while preserving its multi-host netloc.
class
src.docket._result_store.ClusterKeyValueStoreA key-value store that works with RedisCluster.
method
src.docket._result_store.ClusterKeyValueStore.delete(key:str, *collection:str | None=None) -> boolDelete a key-value pair.
method
src.docket._result_store.ClusterKeyValueStore.delete_many(keys:Sequence[str], *collection:str | None=None) -> intDelete multiple key-value pairs.
method
src.docket._result_store.ClusterKeyValueStore.get(key:str, *collection:str | None=None) -> dict[str, Any] | NoneRetrieve a value by key from the specified collection.
method
src.docket._result_store.ClusterKeyValueStore.get_many(keys:Sequence[str], *collection:str | None=None) -> list[dict[str, Any] | None]Retrieve multiple values by key.
method
src.docket._result_store.ClusterKeyValueStore.put(key:str, value:Mapping[str, Any], *collection:str | None=None, *ttl:SupportsFloat | None=None) -> NoneStore a key-value pair with optional TTL.
method
src.docket._result_store.ClusterKeyValueStore.put_many(keys:Sequence[str], values:Sequence[Mapping[str, Any]], *collection:str | None=None, *ttl:SupportsFloat | None=None) -> NoneStore multiple key-value pairs.
method
src.docket._result_store.ClusterKeyValueStore.ttl(key:str, *collection:str | None=None) -> tuple[dict[str, Any] | None, float | None]Retrieve the value and TTL for a key.
method
src.docket._result_store.ClusterKeyValueStore.ttl_many(keys:Sequence[str], *collection:str | None=None) -> list[tuple[dict[str, Any] | None, float | None]]Retrieve multiple values and their TTLs.
class
src.docket.agenda.AgendaA collection of tasks to be scheduled together on a Docket.
method
src.docket.agenda.Agenda.add(function:Callable[P, Awaitable[R]], key:str | None=None) -> Callable[P, None]Add a task function to the agenda.
method
src.docket.agenda.Agenda.clear() -> NoneClear all tasks from the agenda.
class
src.docket.cli._support.TaskStatsStatistics for a single task function.
func
src.docket.cli._support.duration(duration_str:str | timedelta) -> timedeltaParse a duration string into a timedelta.
func
src.docket.cli._support.validate_url(url:str) -> strValidate that the provided URL is compatible with the CLI.
func
src.docket.cli.create_display_layout() -> LayoutCreate the layout for watch display.
func
src.docket.cli.set_progress_start_time(task_id:TaskID, started_at:datetime) -> NoneSet progress bar start time based on execution start time.
class
src.docket.dependencies._base.AdmissionBlockedRaised when a task cannot start due to admission control.
method
src.docket.dependencies._base.CompletionHandler.on_complete(execution:Execution, outcome:TaskOutcome) -> boolHandle task completion.
class
src.docket.dependencies._base.RuntimeBase class for dependencies that control task execution.
class
src.docket.dependencies._base.TaskOutcomeCaptures the outcome of a task execution for handlers.
func
src.docket.dependencies._base.format_duration(seconds:float) -> strFormat a duration for log output.
class
src.docket.dependencies._concurrency.ConcurrencyLimitConfigures concurrency limits for task execution.
func
src.docket.dependencies._contextual.CurrentDocket() -> DocketA dependency to access the current Docket.
func
src.docket.dependencies._contextual.CurrentExecution() -> ExecutionA dependency to access the current Execution.
func
src.docket.dependencies._contextual.CurrentWorker() -> WorkerA dependency to access the current Worker.
class
src.docket.dependencies._cooldown.CooldownExecute first, drop duplicates within window.
class
src.docket.dependencies._cron.CronDeclare a task that should run on a cron schedule.
method
src.docket.dependencies._cron.Cron.initial_when() -> datetimeReturn the next cron time for initial scheduling.
class
src.docket.dependencies._debounce.DebounceWait for submissions to settle, then fire once.
class
src.docket.dependencies._perpetual.PerpetualDeclare a task that should be run perpetually.
method
src.docket.dependencies._perpetual.Perpetual.after(delay:timedelta) -> NoneSchedule the next execution after the given delay.
method
src.docket.dependencies._perpetual.Perpetual.at(when:datetime) -> NoneSchedule the next execution at the given time.
method
src.docket.dependencies._perpetual.Perpetual.on_complete(execution:Execution, outcome:TaskOutcome) -> boolHandle completion by scheduling the next execution.
method
src.docket.dependencies._progress.Progress.current() -> int | NoneCurrent progress value.
method
src.docket.dependencies._progress.Progress.increment(amount:int=1) -> NoneAtomically increment the current progress value.
method
src.docket.dependencies._progress.Progress.message() -> str | NoneUser-provided status message.
method
src.docket.dependencies._progress.Progress.set_message(message:str | None) -> NoneUpdate the progress status message.
method
src.docket.dependencies._progress.Progress.set_total(total:int) -> NoneSet the total/target value for progress tracking.
method
src.docket.dependencies._progress.Progress.total() -> intTotal/target value for progress tracking.
class
src.docket.dependencies._ratelimit.RateLimitCap executions within a sliding time window.
class
src.docket.dependencies._retry.ExponentialRetryConfigures exponential retries for a task.
class
src.docket.dependencies._retry.ForcedRetryRaised when a task requests a retry via `after` or `at`
class
src.docket.dependencies._retry.RetryConfigures linear retries for a task.
method
src.docket.dependencies._retry.Retry.after(delay:timedelta) -> NoReturnRequest a retry after the given delay.
method
src.docket.dependencies._retry.Retry.at(when:datetime) -> NoReturnRequest a retry at the given time.
method
src.docket.dependencies._retry.Retry.handle_failure(execution:Execution, outcome:TaskOutcome) -> boolHandle failure by scheduling a retry if attempts remain.
method
src.docket.dependencies._retry.Retry.in_(delay:timedelta) -> NoReturnDeprecated: use after() instead.
class
src.docket.dependencies._timeout.TimeoutConfigures a timeout for a task.
method
src.docket.dependencies._timeout.Timeout.extend(by:timedelta | None=None) -> NoneExtend the timeout by a given duration.
method
src.docket.dependencies._timeout.Timeout.remaining() -> timedeltaGet the remaining time until the timeout expires.
class
src.docket.execution.DispositionOutcome of a scheduling attempt for an Execution.
method
src.docket.execution.Execution.args() -> tuple[Any, ...]Positional arguments for the task.
method
src.docket.execution.Execution.claim(worker:str) -> boolAtomically check supersession and claim task in a single round-trip.
method
src.docket.execution.Execution.docket() -> 'Docket'Parent docket instance.
method
src.docket.execution.Execution.function() -> TaskFunctionTask function to execute.
method
src.docket.execution.Execution.get_result(*timeout:timedelta | None=None, *deadline:datetime | None=None) -> AnyRetrieve the result of this task execution.
method
src.docket.execution.Execution.key() -> strUnique task identifier.
method
src.docket.execution.Execution.kwargs() -> dict[str, Any]Keyword arguments for the task.
method
src.docket.execution.Execution.mark_as_cancelled() -> NoneMark task as cancelled.
method
src.docket.execution.Execution.mark_as_completed(result_key:str | None=None) -> NoneMark task as completed successfully.
method
src.docket.execution.Execution.mark_as_failed(error:str | None=None, result_key:str | None=None) -> NoneMark task as failed.
method
src.docket.execution.Execution.redelivered() -> boolWhether this message was redelivered.
method
src.docket.execution.Execution.schedule(replace:bool=False, reschedule_message:'RedisMessageID | None'=None) -> DispositionSchedule this task atomically in Redis.
method
src.docket.execution.Execution.trace_context() -> opentelemetry.context.Context | NoneOpenTelemetry trace context.
class
src.docket.execution.ExecutionStateLifecycle states for task execution.
class
src.docket.execution.TaskCallA fully-resolved request to schedule one task.
func
src.docket.testing.assert_no_tasks(docket:Docket) -> NoneAssert that no tasks are scheduled on the docket.
class
src.docket.worker.PubSubMessageMessage received from Redis pub/sub pattern subscription.
class
src.docket.worker.WorkerA Worker executes tasks on a Docket.
method
src.docket.worker.Worker.run_forever() -> NoneRun the worker indefinitely.
method
src.docket.worker.Worker.run_until_finished() -> NoneRun the worker until there are no more tasks to process.
About this data
These signatures were extracted from the public source of chrisguidry/docket
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.