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.9.tar.gz (40.4 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.9-py3-none-any.whl (42.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vercel_workers-0.0.9.tar.gz
  • Upload date:
  • Size: 40.4 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.9.tar.gz
Algorithm Hash digest
SHA256 9baf4cd2cdaf965a00e43ff391522120867ebe6831b6db3664ff4649ff09645d
MD5 c6dc5b5c4b59893e372238c178cb4d6d
BLAKE2b-256 7013e98a11b1dc75c4a09e5665e2ec263ad744d36a7cfc63465af889d4b0cc4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for vercel_workers-0.0.9.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.9-py3-none-any.whl.

File metadata

  • Download URL: vercel_workers-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 42.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vercel_workers-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 1f66ab51c7f19e84c08b19c0a1450a36b32b37257f2181603360722cb3b1872d
MD5 f726e97450b489e8bf514be67c44b4f2
BLAKE2b-256 e9d8584a9b62b1041b5132d2f75663ce82e0de99f76dcd0c246f03cb0af4c6c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for vercel_workers-0.0.9-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