Feature Request
Add the ability to schedule async coroutines alongside regular functions. This is the most requested feature in the upstream project (29+ comments across multiple issues).
Desired API
import schedule
import asyncio
async def async_job():
await some_async_operation()
# Schedule an async coroutine
schedule.every(10).seconds.do(async_job)
# Run with async support
async def main():
while True:
await schedule.async_run_pending()
await asyncio.sleep(1)
asyncio.run(main())
Implementation Notes
- Add an
async_run_pending() method to Scheduler that awaits coroutine jobs
- In
Job.run(), detect if the job function is a coroutine (using asyncio.iscoroutinefunction()) and handle it appropriately
- Keep backward compatibility — regular (sync) jobs must continue to work exactly as before
- Add
run_pending() support for mixed sync/async jobs (sync jobs run normally, async jobs are awaited)
- Do NOT add any external dependencies — use only Python's built-in
asyncio module
- Add comprehensive tests covering:
- Scheduling and running async jobs
- Mixed sync and async jobs in the same scheduler
CancelJob return value from async jobs
- Error handling in async jobs
References
Feature Request
Add the ability to schedule async coroutines alongside regular functions. This is the most requested feature in the upstream project (29+ comments across multiple issues).
Desired API
Implementation Notes
async_run_pending()method toSchedulerthat awaits coroutine jobsJob.run(), detect if the job function is a coroutine (usingasyncio.iscoroutinefunction()) and handle it appropriatelyrun_pending()support for mixed sync/async jobs (sync jobs run normally, async jobs are awaited)asynciomoduleCancelJobreturn value from async jobsReferences