Schedule task in frappe

hi
i have a function that send emails
def say_hi(receiver):
print(“hi”+receiver )

i want it to execute when exception happen put it in queue and schedule it to run in next day after 24 hours .

how can i accomplish this in frappe .
it will be something like :

import copy

def say_hi(receivers)
    rest_of_receivers = copy.copy(receivers)
    for receiver in receivers:
          try:
               print("hi"+receiver )
               rest_of_receivers.remove(receiver)

          except:
               enqueue(say_hi(rest_of_receivers),24hours,"job name say hi after 24 hours date" )

You can attach your function in the scheduler “which requires celery” as cron that is explained in the last portion of this page
https://frappe.io/docs/user/en/guides/basics/hooks

celery dropped down and redis rq come instead in v7

Check this
https://frappe.io/docs/user/en/tutorial/task-runner
and make sure you ran bench enable-scheduler

i don’t think this is what im looking for , it make you called a function from a hook based on time that repeats on a specific time …
what i want is to put it by hand to queue to be executed till the condition meet … then i don’t need it any more !

Are you trying to queueing emails ?

1 Like

if so, check this package Not Found

and frappe.email.queue.send method

1 Like

but send_email function defined to use this function already

if you try to create free sendgrid email … it will allow you only 100 email a day …
what im trying to do is trick that in erpnext
queue will be executed … if this exception occers limited emails … i want it to queue the rest of emails and try again 24 later … so if i have 240 emails
first day 100
second day 100
third day 40 .
and i can see jobs happing in bench doctor and notice whatis going on instaid of useing sleep(24 hours)

http://python-rq.org/ @ahmed-madi the trick must be here :frowning: i’m not expert in it

^ up ^ up ^ up

@ahmadRagheb Did you tried this:

https://github.com/giovanni-codrotech/jobtaskscheduler

Hello @ahmadRagheb , Any solution for the same ?

@JoEz , @rmehta