I have a cron job sending email messages. In order to be within GAE quotas, after each email sent it sleeps for 8 seconds (time.sleep(8)
). In result, the job runs more than 60 seconds and I get CancelledError: The API call logservice.Flush() was explicitly cancelled
exception.
I've found the solution here and started to call logservice.Flush()
manually after each message sent, but it didn't help. So, I am trying to understand the reason. Should I change AUTOFLUSH_ENABLED
to False
to use manual flush?
Why aren't you using the cron to fire off a task which sends the emails, then you have 10 minutes rather than 60 seconds to run the job.
Most of the time, sleeping to reach quotas can be replaced with using task queues, and managing the queue rate, as explained in the documentation.