upstash-qstash
Getting Started
Install
PyPI
pip install upstash-qstash
Get QStash token
Follow the instructions here to get your QStash token and signing keys.
Usage
Synchronous Client
from upstash_qstash import Client
client = Client("<QSTASH_TOKEN>")
def handler():
client.publish_json(...)
if __name__ == "__main__":
main()
Asynchronous Client
import asyncio
from upstash_qstash.asyncio import Client
async def handler():
await client.publish_json(...)
if __name__ == "__main__":
asyncio.run(main())
RetryConfig
You can configure the retry policy of the client by passing the configuration to the client constructor.
Note: This isn for sending the request to QStash, not for the retry policy of QStash.
The default number of attempts is 6 and the default backoff function is lambda retry_count: math.exp(retry_count) * 50
.
You can also pass in False
to disable retrying.
from upstash_qstash import Client
client = Client("<QSTASH_TOKEN>", {
"attempts": 3,
"backoff": lambda retry_count: (2 ** retry_count) * 20,
})