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
>
>

-- 



Reply via email to