Thank you, I'll try it. 2017-11-25 5:31 GMT+01:00 Dave S <[email protected]>:
> > > On Thursday, November 23, 2017 at 12:07:10 AM UTC-8, mweissen wrote: >> >> Thank you - but I think I should explain my question with an example. >> Let's say this is my task in scheduler.py: >> >> def mytask(): >> res = mail.send(some arguments...) >> if res: >> db.emailprotocol.insert(senddata="%s tries before" % >> number_of_tries) >> else: >> do_something_to_repeat_the_task() >> >> (1) If res==False, i.e. if mail.send is not successful: what can I do to >> force another try, to repeat the send process? I have tried to let mytask >> return False, but this did not work. The task becomes COMPLETED. Is there >> any way to let the task FAIL programmatically? My idea was to raise an >> exception. >> >> > Are you seeing that in scheduler_task, or in scheduler_run, or both? > > But raising an exception should work. Most of my "FAIL"s are from > inadvertently raising an exception; both scheduler_run and scheduler_task > then show "FAIL". (Had to refresh distant memories of inner joins in SQL > to check that.) > > > > >> (2) If mail.send is successful, I want to register how many tries have >> been before. And it should be done without a query to the database table. >> >> > Well, I'm not sure how you would do it, and I'm not sure why. The stdout > and the traceback are both in the database table, and it doesn't seem to me > to be a particularly expensive query. > > You can't pass in a session id, and then fill in a variable stored in the > session object, because any session object a worker sees is gone when the > worker is done. Writing something to the filesystem may not be any cheaper > than reading the row from scheduler_run. > > /dps > > > > > /dps > > > 2017-11-22 22:54 GMT+01:00 Dave S <[email protected]>: >> >>> >>> >>> On Wednesday, November 22, 2017 at 9:25:31 AM UTC-8, mweissen wrote: >>> aaa >>> >>>> Two questions: >>>> >>>> (1) Under some conditions (email send not successfully) I want to >>>> force an other try after some minutes. Would it be a good idea to raise an >>>> Exception? >>>> >>>> >>> Who would be raising the exception? >>> >>> >>> >>>> (2) Let's say scheduler_task.retry_failed is 5 and we are in the second >>>> repetition. How can I get these number = 2? Is there any property of >>>> scheduler like scheduler.number_of_try? >>>> >>>> Regards, Martin >>>> >>>> >>> select retry_failed, times_run, times_failed, last_run_time from >>> scheduler_task where times_failed != 0 ; >>> >>> Status should be 'FAILED' on those, as well. >>> >>> And all those values are in the Row object returned by task_status. >>> >>> Footnote: In the online book (as at web2py.com/books), the search >>> function with the term "scheduler" finds -K option in the command line help >>> list, but doesn't find the API discussion also in Chapter 4. I did get >>> there by searching for "queue_task". I'm not familiar with the guts of the >>> search function to know why this happens. >>> >>> /dps >>> >>> >>> >>> -- >>> Resources: >>> - http://web2py.com >>> - http://web2py.com/book (Documentation) >>> - http://github.com/web2py/web2py (Source code) >>> - https://code.google.com/p/web2py/issues/list (Report Issues) >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "web2py-users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

