Skip to content

Scheduled Task (scheduled_task) ​

Adds a periodic background task. @provider(points.SCHEDULED_TASK, id=...) returns a ScheduledTask.

python
from ab_sdk.tasks import ScheduledTask

@provider(points.SCHEDULED_TASK, id="sync")
def sync(self):
    async def run() -> None:
        ...

    return ScheduledTask(run, interval=lambda: self.config.interval, initial_delay=60)
FieldDescription
runAn async function with no parameters
intervalThe wait between two runs, in seconds. It can be a function. AB reads it again each round, so it follows configuration changes
initial_delayThe seconds to wait before the first run. Default 0
enabledAn optional function. If it returns False, AB skips that round
  • The task runs only while the program runs. It starts and stops together with built-in tasks such as the RSS refresh.
  • An exception from run counts toward the plugin breaker.
  • The interval starts when the previous run ends. It is not a fixed beat.

AutoBangumi is released under the MIT License. (latest: v3.3.2)