SQS Broker for TaskIQ
Project description
TaskIQ SQS Broker
Mostly generic SQS async broker for TaskIQ.
Expiration
If you set the sqs_expiry
label to a unix timestamp, the message will be discarded if the worker receives it after that time.
import asyncio
from taskiq_sqs import SQSBroker
broker = SQSBroker("http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/my-queue")
@broker.task
async def add_one(value: int) -> int:
return value + 1
async def main() -> None:
# Never forget to call startup in the beginning.
await broker.startup()
# Send the task to the broker.
task = await add_one.kiq(1)
# Wait for the result. (result backend must be configured)
result = await task.wait_result(timeout=2)
print(f"Task execution took: {result.execution_time} seconds.")
if not result.is_err:
print(f"Returned value: {result.return_value}")
else:
print("Error found while executing task.")
await broker.shutdown()
if __name__ == "__main__":
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
taskiq_sqs-0.0.11.tar.gz
(17.8 kB
view hashes)
Built Distribution
Close
Hashes for taskiq_sqs-0.0.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c81eeec76c12e686a5f28061ded18bbc53f52942c44f9a950b2e7f1d968b5767 |
|
MD5 | c452acaf53dba4faa2825f65f26786e3 |
|
BLAKE2b-256 | 1e2a50bc4dd4b7f638c56fc001c54524378bba38d61c9ab6e69c1079f6a54ab5 |