Skip to main content

Python SDK for Vercel Workers

Project description

vercel-workers

Installation

pip install vercel-workers

Django 6.0 django.tasks integration (Vercel Queues)

This repo ships an optional django.tasks backend that enqueues tasks into Vercel Queues and executes them via a queue callback route (similar in spirit to the Celery integration in this repo).

Install

pip install "vercel-workers[django]"

Configure Django

In settings.py:

TASKS = {
    "default": {
        "BACKEND": "vercel.workers.django.backend.VercelQueuesBackend",
        # Optional: restrict which Django queue_name values are allowed.
        "QUEUES": ["default"],
        "OPTIONS": {
            # TaskResult storage (uses Django cache; for production prefer Redis).
            "cache_alias": "default",
            "result_ttl_seconds": 86400,

            # Callback execution settings (visibility/lease).
            "visibility_timeout_seconds": 30,
            "visibility_refresh_interval_seconds": 10.0,

            # Basic retry policy for task exceptions.
            "max_attempts": 3,
            "retry_backoff_base_seconds": 5,
            "retry_backoff_factor": 2.0,

            # Optional publish-time overrides passed through to vercel.workers.client.send()
            # (you can also set env vars like VERCEL_QUEUE_TOKEN / VERCEL_QUEUE_BASE_URL).
            # "token": "...",
            # "base_url": "...",
            # "base_path": "...",
            # "retention_seconds": 86400,
            # "deployment_id": "...",
            # "timeout": 10.0,
        },
    }
}

Define and enqueue tasks

from django.tasks import task


@task(queue_name="default")
def send_email(to: str) -> None:
    ...


result = send_email.enqueue(to="user@example.com")

Expose the Vercel Queue callback route

You must expose a WSGI/ASGI endpoint that Vercel Queues can POST CloudEvents to:

  • WSGI: vercel.workers.django.get_wsgi_app(backend_alias="default")
  • ASGI: vercel.workers.django.get_asgi_app(backend_alias="default")

How you mount that depends on your deployment setup (Vercel Python entrypoint / framework).

Notes / limitations

  • Queue naming: Django Task.queue_name maps directly to the Vercel Queue name you publish to.
  • Priority: not supported (Django Tasks will validate priority is default).
  • run_after: supported by delaying the queue message (visibility timeout) when it is delivered early.
  • Results: stored in Django cache. With LocMemCache, get_result() is process-local; for real cross-request results use Redis (or another shared cache backend).

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

vercel_workers-0.0.10.tar.gz (49.1 kB view details)

Uploaded Source

Built Distribution

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

vercel_workers-0.0.10-py3-none-any.whl (52.0 kB view details)

Uploaded Python 3

File details

Details for the file vercel_workers-0.0.10.tar.gz.

File metadata

  • Download URL: vercel_workers-0.0.10.tar.gz
  • Upload date:
  • Size: 49.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vercel_workers-0.0.10.tar.gz
Algorithm Hash digest
SHA256 6f8bc619ab9e844d3ddae3a40bc7dce2cec93a8cbd3d680b1223c393fa9d9c45
MD5 783f37757d0378ea1b8f0ffddd84ebbc
BLAKE2b-256 d47cb1fb0e55b9b277e80f88f7e9136f83fde9173aa60aef6a5f8beaf36a2feb

See more details on using hashes here.

Provenance

The following attestation bundles were made for vercel_workers-0.0.10.tar.gz:

Publisher: publish.yaml on vercel/vqs-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vercel_workers-0.0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for vercel_workers-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 1a1f641938a5830c8d2235c000fef305c1fe916329b2726cf068afb1c3093aa3
MD5 727939dc2b45dbeb51a61ff75466e3e3
BLAKE2b-256 7f1c36c4e5d46f43adf0827392437fcd24ee8b16473eee5aeca06cf559f0ce1f

See more details on using hashes here.

Provenance

The following attestation bundles were made for vercel_workers-0.0.10-py3-none-any.whl:

Publisher: publish.yaml on vercel/vqs-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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