0

I'm facing a bit of a problem using ndb post_put_hook to add something in a taskqueue. I've created the hook in my model, and whenever a put() is done, the hook gets executed indefinitely. If I do anything else but add something to a taskqueue, it works fine, the hook gets executed only once.

When i do this:

class MyModel(ndb.Model):
    name = StringProperty()

    def _post_put_hook(self, future):
        logging.info("Doing Something")

MyModel(name="myname").put()

The output is:

Doing Something

However, doing this:

class MyModel(ndb.Model):
    name = StringProperty()

    def _post_put_hook(self, future):
        logging.info("Adding a task")
        taskqueue.add(...)

MyModel(name="myname").put()

The output is:

Adding a task
Adding a task
Adding a task
...
Adding a task

From there I have to stop the SDK otherwise it keeps getting executed. FYI the task is added properly (although many many times) and returns a 200 each time.

This is the first time I'm using hooks like that, so maybe there's something I'm missing here. Any clue ?

Thanks !

brian
  • 802
  • 4
  • 18

1 Answers1

0

So I've figured out what's the issue: somewhere in my task I perform another put() on the same doc, which explains this behaviour.

brian
  • 802
  • 4
  • 18
  • 3
    I think there's a way to close your own question, since this was about a bug in your own code and you didn't show us all the code. – Guido van Rossum Jul 04 '13 at 17:02