quick-artist-10782
02/16/2025, 8:57 PMgray-monkey-83525
02/16/2025, 8:57 PMquick-artist-10782
02/16/2025, 8:58 PMgray-monkey-83525
02/16/2025, 8:58 PMimport asyncio
from livekit import api
async def run_job_with_retry(job_function, max_retries=3, delay=2):
retries = 0
while retries < max_retries:
try:
await job_function()
break # Exit loop if job succeeds
except Exception as e:
print(f"Job failed with error: {e}. Retrying {retries + 1}/{max_retries}...")
retries += 1
await asyncio.sleep(delay)
else:
print("Max retries reached. Job failed.")
async def example_job():
# Simulate a job that might fail
if some_condition_that_causes_failure:
raise Exception("Simulated job failure")
print("Job succeeded")
# Usage
asyncio.run(run_job_with_retry(example_job))
In this example, run_job_with_retry
is a function that attempts to run a job function up to a specified number of retries (max_retries
). If the job fails, it waits for a specified delay before retrying. If the job succeeds, it exits the loop. If the maximum number of retries is reached, it logs a failure message.
If you need more detailed guidance or have specific requirements, please let me know.
Sources:
- https://livekit-users.slack.com/archives/C07FY8WHGPM/p1731010287.780029
- https://docs.livekit.io/python/livekit/plugins/google/index.html#livekit.plugins.google.SpeechStream
Note: I wasn’t able to find highly relevant data sources, but above are a few potentially relevant links. 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.