Tasks
Methods can also be executed asynchronously. We call these "tasks". You can schedule the execution of a method using the schedule()
builder method:
- Python
- TypeScript
task = await self.lookup().schedule().WelcomeEmailTask(context)
const task = await this.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:
- Python
- TypeScript
await self.lookup().schedule(
when=timedelta(seconds=request.quote_expiration_seconds),
).ExpireQuoteTask(
context,
quote=quote,
)
await this.lookup().schedule({ when }).expireQuoteTask(context, { quote })