How It Works

Here is how the module works.

  • Adding Tasks: When you add a task, you provide a function that runs the task, set its priority, and can also add a timeout or metadata (extra info about the task).

  • Running Tasks: Tasks can run in parallel (many at once) or in sequence (one at a time). The TaskScheduler automatically decides when to run tasks based on their priority and if they have any dependencies.

  • Task Retry System: If a task fails, it will retry based on the strategy you’ve set (try again immediately, wait longer each time, or add a random delay).

  • Throttling: Some tasks can be "throttled," meaning they can only run after a certain amount of time has passed, which is useful for rate-limiting tasks that shouldn't run too frequently.

  • Error Handling: If a task keeps failing after all retries, the TaskScheduler can handle it globally and log the issue.

Last updated