Should manual logservice flush work with automatic

2019-07-31 16:13发布

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?

2条回答
再贱就再见
2楼-- · 2019-07-31 16:43

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.

查看更多
对你真心纯属浪费
3楼-- · 2019-07-31 16:47

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.

查看更多
登录 后发表回答