Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for async jobs #438

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

None yet

1 participant