Saxon Druce
Saxon Druce

Reputation: 17624

App Engine: Is it possible to enqueue tasks asynchronously?

Many of my handlers add a task to a task queue to do non-critical background processing. Since this processing isn't critical, if the call to taskqueue.add() throws an exception, my code just ignores it.

Tonight the task queue seemed to be down for around half an hour. Although my handlers correctly ignored the failure, they took about 5 seconds for the taskqueue.add() call to timeout and move on to processing the rest of the page. This therefore made my site run very slowly.

So, is it possible to enqueue a task asynchronously - meaning a way to add a task, without waiting to see if the addition succeeded?

Alternatively, is there a way to reduce that timeout from 5 seconds down to eg 1 second?

Thanks.

Upvotes: 1

Views: 227

Answers (3)

stevep
stevep

Reputation: 959

I am pretty sure GAE announced that TQ adds will be async with the next release (experimental feature).

Upvotes: 0

Eric Willigers
Eric Willigers

Reputation: 1806

You can use the new taskqueue methods create_rpc and add_async. If you don't care if the add succeeds, simply call add_async and ignore the result. If you care, but only want to wait 1 second, set the deadline when calling create_rpc, and use the return value as the RPC argument to add_async. Call get_result to find out if the tasks were successfully added.

Upvotes: 1

systempuntoout
systempuntoout

Reputation: 74064

I think you can't do anything about it because the RPC call underneath the add method is a synchronous blocking API call.

You could try to add some check using the Capabilities API.

Upvotes: 1

Related Questions