{"id":930,"library":"docket","title":"Docket","description":"Docket is a Python library that provides a distributed background task system for executing Python functions. It is currently at version 0.18.2 and maintains an active development cycle with frequent releases, offering robust solutions for task scheduling and execution.","status":"active","version":"0.18.2","language":"python","source_language":"en","source_url":"https://github.com/chrisguidry/docket","tags":["async","tasks","background","distributed","scheduling","cron","worker"],"install":[{"cmd":"pip install docket","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Dependency injection and task dependency management were extracted into this separate library in version 0.18.0. It is a core architectural component of Docket.","package":"uncalled-for","optional":false}],"imports":[{"symbol":"Docket","correct":"from docket import Docket"},{"symbol":"task","correct":"from docket import task"},{"note":"Used for defining tasks that run on a cron schedule.","symbol":"Cron","correct":"from docket.dependencies import Cron"}],"quickstart":{"code":"import asyncio\nfrom docket import Docket, task\n\n@task\nasync def greet_task(name: str):\n    \"\"\"An example asynchronous task.\"\"\"\n    print(f\"Hello, {name}!\")\n    return f\"Greeted {name}\"\n\nasync def main():\n    # Initialize Docket. In a real application, you might configure a backend like Redis.\n    docket = Docket()\n\n    # Add the task to be run. This queues it for execution.\n    await docket.add(greet_task, name=\"World\")\n    print(\"Task added. Running Docket...\")\n\n    # Run Docket. In a long-running service, this would be awaited indefinitely.\n    # For a quickstart, we'll run it briefly to allow the task to execute.\n    # For simplicity, we'll assume the task completes quickly.\n    try:\n        await asyncio.wait_for(docket.run(), timeout=5) # Run for max 5 seconds\n    except asyncio.TimeoutError:\n        print(\"Docket run timed out after 5 seconds.\")\n\nif __name__ == \"__main__\":\n    asyncio.run(main())","lang":"python","description":"A minimal example demonstrating how to define an asynchronous task and run it using Docket. This example uses the default in-memory backend."},"warnings":[{"fix":"No direct code changes are typically required, as `uncalled-for` is installed as a dependency of `docket`. However, if experiencing issues, ensure `uncalled-for` is correctly installed and consult its documentation if custom dependency injection logic was previously implemented.","message":"From version 0.18.0, Docket's internal dependency system was extracted into the `uncalled-for` library. While intended to be a transparent change for most users, deep or custom integrations with Docket's dependency resolution might require review.","severity":"breaking","affected_versions":"0.18.0+"},{"fix":"Ensure all I/O-bound or long-running operations within tasks are non-blocking or are offloaded to an executor (e.g., `loop.run_in_executor`) to prevent blocking the `asyncio` event loop. Always `await` asynchronous calls.","message":"Docket tasks are fundamentally asynchronous (`async def`) and rely on `asyncio`. Incorrectly mixing synchronous code in an async task, or blocking the event loop, can lead to performance issues or deadlocks.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Explicitly specify the timezone using the `tz` argument in the `Cron` constructor (e.g., `Cron('0 0 * * *', tz='America/New_York')`). Verify that your system's timezone settings are consistent across all Docket worker nodes.","message":"When using `Cron` dependencies for task scheduling, ensure careful consideration of timezones. Default behavior might rely on the system's local timezone, which can lead to unexpected execution times in distributed or timezone-aware applications.","severity":"gotcha","affected_versions":"All versions, improved in 0.17.5"},{"fix":"Refer to the Docket documentation for the specific backend chosen. Implement proper connection pooling, error handling, and retry mechanisms for backend connections. Misconfigurations can lead to lost tasks or inconsistent state.","message":"Using persistent backends (e.g., Redis, PostgreSQL) requires robust configuration and connection management to ensure tasks are reliably stored, retrieved, and processed across application restarts and distributed environments.","severity":"gotcha","affected_versions":"All versions using persistent backends"},{"fix":"Verify the correct package name (`docket`) and ensure it is published to PyPI or your configured package repository. Check network connectivity and `pip` configuration if using private repositories or proxies. If `docket` is not yet released, consider installing directly from source if available.","message":"The `docket` package could not be found or installed from the available package index (e.g., PyPI). This typically indicates that the package is not published, the package name is misspelled, or the Python environment lacks access to the package index.","severity":"breaking","affected_versions":"All versions"},{"fix":"Before attempting installation, verify Docket's PyPI page or documentation for supported Python versions and available distributions for your target environment. Consider using an officially supported Python version (e.g., 3.8-3.12) if encountering issues with newer releases or specific environments like Alpine Linux.","message":"The `docket` library might not have pre-built wheels or be available for installation on all Python versions or architectures, particularly for newer Python releases (e.g., Python 3.13) or less common operating systems/architectures (e.g., Alpine Linux). This can lead to installation failures.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T21:23:25.960Z","next_check":"2026-06-27T00:00:00.000Z","problems":[{"fix":"Install the correct package: `pip install pydocket` or `uv pip install pydocket`.","cause":"The Python package for the 'docket' library is published under the name 'pydocket' on PyPI, not 'docket'.","error":"ModuleNotFoundError: No module named 'docket'"},{"fix":"Ensure a Redis server (version 5.0.0 or higher) is running and accessible at the specified host and port, and that no firewall is blocking the connection. You can also specify the Redis URL when initializing Docket: `Docket(url=\"redis://your_redis_host:port\")`.","cause":"The `docket` library requires a running Redis server with Streams support, and this error indicates the client cannot connect to it.","error":"redis.exceptions.ConnectionError: Error 111 connecting to 127.0.0.1:6379. Connection refused."},{"fix":"Schedule tasks using the `docket.add()` method: `await docket.add(your_async_task)(arg1, arg2)` instead of `your_async_task.delay(arg1, arg2)`.","cause":"Unlike some other background task libraries (e.g., Celery), `docket` does not use a `.delay()` method on task functions. Tasks are plain async functions scheduled using `docket.add()`.","error":"AttributeError: 'function' object has no attribute 'delay'"},{"fix":"Register your task functions with the worker using `worker.register(your_task_function)` or pass a collection of tasks via CLI: `docket worker --tasks your_module:your_task_collection`.","cause":"Docket workers need to be explicitly registered with the tasks they are expected to process. If tasks are not registered, the worker won't know about them and will not execute them.","error":"Tasks are not being processed by the worker."}],"ecosystem":"pypi","meta_description":null,"install_score":0,"install_tag":"stale","quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"docket","install_checks":{"last_tested":"2026-05-12","tag":"stale","tag_description":"widespread failures or data too old to trust","installed_version":null,"pypi_latest":null,"is_stale":null,"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.5,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.4,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.3,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.3,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":1.6,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"docket","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":null,"tag_description":null,"results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}