Skip to main content

Tasks

Methods can also be executed asynchronously. We call these "tasks". You can schedule the execution of a method using the schedule() builder method:

task = await self.lookup().schedule().WelcomeEmailTask(context)

With no arguments to schedule(), we'll run the method immediately in the background, and will retry until it completes.

You can additionally pass the when argument to schedule the execution for a point in the future:

await self.lookup().schedule(
when=timedelta(seconds=request.quote_expiration_seconds),
).ExpireQuoteTask(
context,
quote=quote,
)