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 !