Question

I am surprised to see this error (and not even documented in the quotas)...

Exceeding 100KB, I get this error:

TaskTooLargeError: Task size must be less than 102400

Any ideas on how to handle this?

The context: the body of emails (HTML) are being passed as arguments to a task queue.

Was it helpful?

Solution

You should store the body of the html in the datastore and then pass the key of that entity to the task.

The same approach is taken if you have an instance of a Model that you want to pass to a task. You normally pass the key of the entity, and the task can then fetch it.

Normally if I want to defer a method as a task I create a classmethod for an entity that takes the key as an argument, then it fetches the object, and then calls the actual method of the object. The I can either call the method direct on the entity, or deferr things when needed.

e.g.

@classmethod
def defer_cancel_supervisor(cls,contract_key):

    contract = qtrack.models.Contract.get(db.Key(contract_key))
    contract.cancel_supervisor('contract cancelled')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top