kibertoad / toad-scheduler

In-memory Node.js and browser job scheduler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How does scheduler.stop() work with AsyncTask?

PierBover opened this issue · comments

I'm sorry for using issues to ask a question but after looking at the code and docs I can't seem to find an answer to this.

What happens when I use scheduler.stop() and an async task is still running?

If I'm following the code correctly, when the task is sync the scheduler would stop after the current task has finished. But I haven't seen any code to wait for an async task to finish before stopping the scheduler.

Thank you for the question! I think I need to update documentation on this.

Stopping scheduler doesn't interrupt a task if it's already running, it will only avoid starting new tasks.

Please let me know if that answers your question!

Would it be helpful if scheduler would return a promise that only resolves after all tasks finish execution?

Would it be helpful if scheduler would return a promise that only resolves after all tasks finish execution?

Yes it would be great to be able to do await scheduler.stop(). Thanks @kibertoad !

@PierBover Could you please open another issue for await scheduler.stop?