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:

# entry/settings.py
UNFAZED_TASKIQ_SETTINGS = {
    "BROKER": {
        "BACKEND": "taskiq.InMemoryBroker",
        "OPTIONS": {},
    },
    "RESULT": {
        "BACKEND": "taskiq_redis.RedisAsyncResultBackend",
        "OPTIONS": {
            "redis_url": "redis://redis:6379",
        },
    },
    "SCHEDULER": {
        "BACKEND": "taskiq.scheduler.scheduler.TaskiqScheduler",
        "SOURCES_CLS": ["taskiq.schedule_sources.LabelScheduleSource"],
    },
}

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

Use UnfazedTaskiqAgent in your app's tasks.py:

# 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.2.tar.gz (49.7 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.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for unfazed_taskiq-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c3b2260b20815ccebb92dba5b89e25e0850693894ecfbd88495b0ef3903d58a6
MD5 66f094c93eb65d74a09ceea81ea05d8d
BLAKE2b-256 6e2e9945139b1533e6614cc9c05d95f46ed9c4564e48fe6572a70647621dcb61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unfazed_taskiq-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e8b62513af1207d1a7f2971cae9545502d168913ad64d390373059776aa8a47a
MD5 d3855092a1feab75a6520e721fc70e83
BLAKE2b-256 6d7259ce6f0f1fdd917cb337c3679b08b5043477e63b3cb12698c9772dbebe79

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