Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If a task is queued successfully, it will eventually execute. (And App Engine will keep trying for as long as it takes.)</p> <p>The pattern you show might be better implemented using <a href="https://developers.google.com/appengine/docs/python/config/cron" rel="nofollow">cron jobs</a>, though, which run a task on a regular basis. A common pattern I use is to have a daily cron job kick off a task on a task queue with a small number of retries (so that if there's a temporary glitch, it will retry immediately). </p> <p>If you do want to use the method above, rather than cron, there's another thing to worry about: since your method can be retried due to it failing or other system issues (e.g. the instance running it going down) you should make sure that you don't end up with two tasks. Imagine if it ran, registered the next task and then the node went down; App Engine would retry, starting a second task. To prevent this, you could use the data store (in a transaction) to test and see if the next task has already been enqueued. Something like:</p> <pre><code>def do_work(counter): ... @db.transactional def start_next(): # fetch myModel from the data store here if myModel.counter == counter: return # already started next job myModel.counter = counter myModel.put() deferred.defer(do_work, counter + 1, _transactional=True, _countdown=...) start_next() </code></pre> <p>Note the "transactional" argument in the defer call; this ensures that the MyModel instance will be updated if and only if the next task is enqueued. </p> <p>You might also want to look into sending an email to an administrator after a certain number of failed retries. (You can find this in the request HTTP headers, but you can't use the deferred library if you want to do this; you have to use the task queue API directly.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload