Back

Run function 30 minutes from now (delayed function)

  • 0
  • Functions
  • Webhooks
Vinicius Brito
5 Jun, 2023, 22:52

How can I get a function to run 30 minutes after an event, say, to send additional emails in reaction to a user sign up. Scheduled functions apparently only allow for recurring functions (daily, weekly, every tuesday etc etc), but I want a delayed function.

TL;DR
You cannot directly create a delayed function in Appwrite. Scheduled functions are only for recurring tasks. One workaround could be to use counters linked to the event, but it may not work for a 30-minute delay. Another option is to create a function that checks the current time until the scheduled time is reached using a loop and the `time.sleep(1)` function. However, note that the maximum execution time for a function in Appwrite is 15 minutes, so this solution may not be ideal.
Dakshie
5 Jun, 2023, 23:07

I don't think there is any feature as a delayed function,

But maybe you can create a function thats something like this

TypeScript
        time.sleep(1)
        current_time = datetime.now()```
Dakshie
5 Jun, 2023, 23:09

But then, the max execution time of a function in appwrite is 15mins

Dakshie
5 Jun, 2023, 23:10

It won't work for a 30 mins delay🤔

joeyouss
6 Jun, 2023, 03:02

Delayed functions, hmm, interesting

for something like scheduled functions, you would do something like this https://medium.com/@ujjwal26599/leveraging-power-of-appwrite-to-build-scheduling-applications-40615fa7e7f7

But since you do not want that, maybe you can use counters that are silently triggered upon your event and linked with it.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more