agronholm / apscheduler

Task scheduling library for Python
MIT License
5.98k stars 694 forks source link

Arbitrarily fired triggers. #818

Closed nuno-andre closed 2 months ago

nuno-andre commented 8 months ago

Things to check first

Feature description

It would be great to leverage the events system to able to launch jobs programmatically. Something like:

    ...
    async with AsyncScheduler() as scheduler:
        await scheduler.add_schedule(fn, EventTrigger(), id='some_id')
    ...

And then, from elsewhere in the code:

    ...
    event = TriggerEvent(id='some_id')
    await event.fire()
    ...

I have tried to do it myself but I have to pass the scheduler to the trigger, current_async_scheduler returns None at initialization.

Use case

Probably none that is not covered by .add_job(), but it could simplify many workflows.

agronholm commented 8 months ago

How would the EventTrigger class work? I'm not comprehending this.

agronholm commented 2 months ago

Closing due to lack of responses.