Skip to content

Conversation

@SijmenHuizenga
Copy link
Collaborator

This is a draft implementation of supporting async jobs by adding run_pending_async and run_all_async. These methods would support both normal jobs and coroutine jobs. An usage example:

import asyncio
import schedule

def fooJob():
    print("Foo")

async def barJob():
    print("Bar")

schedule.every(3).seconds.do(fooJob)
schedule.every(2).seconds.do(barJob)

async def execute():
    while True:
        await schedule.run_pending_async()
        await asyncio.sleep(1)

loop = asyncio.get_event_loop()
loop.run_until_complete(execute())
loop.close()

This pr is far from finished. I'm submitting this in such an early stage to continue the conversation about async implementations started in #357. The implementation in this pr is roughly based on the work by @pirroman in pr #357.

I am keen to hear what you think about supporting async in this way.

Pwnion added a commit to Pwnion/schedule that referenced this pull request Jan 16, 2024
Incorporated changes from SijmenHuizenga's pull request (dbader#438) to add async support.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant