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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for unfazed_taskiq-0.0.1.tar.gz
Algorithm Hash digest
SHA256 375b5d6c10041d96308898756c3479f416bd16f67e6979e55c89c29cd49b8df5
MD5 57d32e499a6159124765e0a10d2a49b7
BLAKE2b-256 2604e54a6025cd832e5f420a7fbf3aef0571d386b8086dde37265e400000e219

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unfazed_taskiq-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2613b508d70bd914bae049a6f88f7238262a185dfedcea0edbe3d41105b2b5d4
MD5 975936ac1e4aa568a62a0984eadbf00d
BLAKE2b-256 09f7e5ecf855176a3de5a4a7e4587a31bda63be671e7b699ea48d0761fbff4e9

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