let's go in order: 1. the scheduler env is the same as your app's. As long as the mailer is defined and working for the app, you can use it in a queued task 2. as there's no way to let an external process live, and the scheduler being a totally separate process from the web-related one, the scheduler can't be used on GAE. Not a web2py limitation but a GAE one, that does provide an "offloading tasks pattern" with their "Task Queue" solution. GAE attachments and encryption: some python libraries aren't available at all on GAE. again, not a web2py limitation rather a GAE one 3. the whole point is that if you code a long-running task and it doesn't complete, with cron you may end up with two processes sending the same mails (as the showed snippet commit()s at the end of the loop). The scheduler is a lot safer in that regard: every task can only be executed by a single worker at any given time. Concurrency with the scheduler is achieved starting more than a worker process and having more than a queued task (i.e. 5 workers with 10 similar queued tasks will be parallelized with each worker getting a slot of 2 tasks each) 4. for statistical purposes. if you don't need scheduler_run records, you can either: - code a task that doesn't return any data (the scheduler_run entry won't be kept except for failing tasks) - pass discard_results=True argument to the scheduler
On Wednesday, March 2, 2016 at 4:21:46 PM UTC+1, noam cohen wrote: > > Hi > I have the following scenario: > A scheduled task runs every T seconds (e.g. 60), and executes a function > F() > In function F() I scan some db tables and according to the business logic, > may need to send several email messages. > > The book ( > http://www.web2py.com/books/default/chapter/29/08/emails-and-sms#Sending-messages-using-a-background-task) > > uses an ad-hoc queue rather than the Scheduler. I want to use the Scheduler > system > 1. How can the worker process access the mailer object? I think it cannot > be passed in the queue_task() > > 2. "At the time of writing web2py does not support attachments and > encrypted emails on Google App Engine. Notice cron and scheduler do not > work on GAE." Is this still true? If yes, I should keep away from the > scheduler. > > 3. scheduler workers doing work in parallel: "As noted in Chapter 4, this > type of background process should not be executed via cron (except perhaps > for cron @reboot) because you need to be sure that no more than one > instance is running at the same time." > -- so if I need to send 5 emails, they have to be serialized ? why? > > 4. Why are old tasks kept in table scheduler_run ? are they purged > automatically or I have to delete them manually? > > * I DID read the other posts on this topic before writing my own... > > (running v 2.12.3) > > Thanks! > Noam C. > > > -- 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.

