Skip to main content

Taskiq Plugin for Unfazed

Project description

Unfazed Taskiq

taskiq wrapper with unfazed.

Installation

pip install unfazed-taskiq

Quick Start

Add settings to your unfazed settings file:

from taskiq_redis import ListRedisScheduleSource
redis_resource = ListRedisScheduleSource(url=f"redis://{REDIS_HOST}:6379")

# entry/settings.py
UNFAZED_TASKIQ_SETTINGS = {
    "BROKER": {
        "BACKEND": "taskiq.InMemoryBroker",
        "OPTIONS": {},
    },
    "RESULT": {
        "BACKEND": "taskiq_redis.RedisAsyncResultBackend",
        "OPTIONS": {
            "redis_url": "redis://redis:6379",
        },
    },
    # Sources can be a list of strings or ScheduleSource instances
    "SCHEDULER": {
        "BACKEND": "taskiq.scheduler.scheduler.TaskiqScheduler",
        "SOURCES": ["taskiq.schedule_sources.LabelScheduleSource", redis_resource],
    },
}

# add lifespan to your settings
UNFAZED_SETTINGS = {
    "LIFESPAN": ["unfazed_taskiq.lifespan.TaskiqLifeSpan"],
}

Use UnfazedTaskiqAgent in your app's tasks.py:

Note: Sources can be a list of strings or ScheduleSource instances, when it's a string, it will be imported and instantiated with args broker from BROKER in settings.

# app/tasks.py
from unfazed_taskiq import agent

@agent.broker.task
async def add(a: int, b: int) -> int:
    return a + b


@agent.broker.task(schedule=[{"crontab": "*/1 * * * *", "args": [1, 2]}])
async def add_schedule(a: int, b: int) -> int:
    return a + b

Kick off tasks

from .tasks import add

async def your_service():
    await add.kiq(1, 2)

Start Taskiq Worker or Scheduler

taskiq worker unfazed_taskiq.cli:broker

# or
taskiq scheduler unfazed_taskiq.cli:scheduler

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

unfazed_taskiq-0.0.3.tar.gz (50.0 kB view details)

Uploaded Source

Built Distribution

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

unfazed_taskiq-0.0.3-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file unfazed_taskiq-0.0.3.tar.gz.

File metadata

  • Download URL: unfazed_taskiq-0.0.3.tar.gz
  • Upload date:
  • Size: 50.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.9

File hashes

Hashes for unfazed_taskiq-0.0.3.tar.gz
Algorithm Hash digest
SHA256 ad08768ce21356e963ab5799bc1f54582bb349a42b271040d17c1ebe7957952c
MD5 69d6fa1ce1f0ec3e69fa46cf7a1739c4
BLAKE2b-256 ea54d97fe877548c05118216bc2fe6cc4195821cdf18f86f6d0a14dcd3ff7d97

See more details on using hashes here.

File details

Details for the file unfazed_taskiq-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for unfazed_taskiq-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a960602773030ca0e2fadb7c5a5ca8c129c0b4ebdbc21875fa276376d6dc44a3
MD5 3a3832a4c4726013e41a4edefc958132
BLAKE2b-256 404aadf54ec9265927429f752b4ef0cbd934bc9cec00e596e8617c2bc1b05db6

See more details on using hashes here.

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