Yes, I am using mysql. I've accidentally posted this twice [0] on the group (sorry for that). Anthony asked: > How are emails added to the database -- does that happen within the application, or also in a script?
Emails are added to the database from within the application (a controller function adds a confirmation email to the queue) [0] https://groups.google.com/forum/?fromgroups#!topic/web2py/YT2jDMea6lU On Sunday, 12 August 2012 07:17:39 UTC+12, Massimo Di Pierro wrote: > > Are you using mysql? > > On Friday, 10 August 2012 23:11:03 UTC-5, Florian Letsch wrote: >> >> I want to send emails using a background queue as described in the web2py >> book: >> http://web2py.com/books/default/chapter/29/8#Sending-messages-using-a-background-task >> >> However, the queue only sends emails that have been in the database when >> I start the script. Database entries added lateron don't get picked up by >> the script. The only way I can achieve that is to add another db.commit() >> before the select(). I am sure this is not supposed to be necessary. Does >> anyone know why this is happening? >> >> import time >> while True: >> db.commit() # Only works if I add this line >> rows = db(db.queue.status=='pending').select() >> for row in rows: >> if mail.send(to=row.email, >> subject=row.subject, >> message=row.message): >> row.update_record(status='sent') >> else: >> row.update_record(status='failed') >> db.commit() >> time.sleep(60) # check every minute >> >> --