Retry your functions later, asynchronously
Project description
retry_later
@retry_later
allows you to retry the execution of a function asynchronously in the background until it's done.
Why?
For example, you can retry sending an email until it's sent.
Installation
pip install retry-later
Usage
Simply add @retry_later()
to your function. This also works with async
functions.
Look inside the examples
folder for more examples!
Here's a simple demonstration:
from my_very_python_real_email_client import send_mail_to_friend, send_text_to_friend
import asyncio
# Create new event loop
loop = asyncio.new_event_loop()
# Import the decorator
from retry_later import retry_later
@retry_later(retry_interval=10, max_retries=5, exception=ConnectionError)
def send_email():
send_mail_to_friend(email="veryrealperson@veryrealemail.haha", body="hi!")
@retry_later(retry_interval=10, max_retries=5, exception=ConnectionError)
async def send_a_text():
await send_text_to_friend(number="+123456789", body="hi! texting you")
send_email()
asyncio.run(send_a_text())
# Other stuff
print("Hi - I am here!! I complete before my_function!")
# event loop must be running for retry_later to work
loop.run_forever()
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
retry_later-0.0.4.tar.gz
(5.0 kB
view hashes)
Built Distribution
Close
Hashes for retry_later-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04cb34e003c6282b4ced6ecf7c8fbb110b0af04253e382565e60a56550c249df |
|
MD5 | 28e87adcd62a26d2b46a6e1a00964a24 |
|
BLAKE2b-256 | 62a4e41fac287f7993b29e35a432118567df6dc42c3abeea3b5d3258e6aed1d4 |