Is get_result() a required call for put_async() in Google App Engine

With the new release of GAE 1.5.0, we now have an easy way to do async datastore calls. Are we required to call get_result() after calling 'put_async'?

For example, if I have an model called MyLogData, can I just call:

put_async(MyLogData(text="My Text"))

right before my handler returns without calling the matching get_result()? Does GAE automatically block on any pending calls before sending the result to the client?

Note that I don't really care to handle error conditions. i.e. I don't mind if some of these puts fail.

Answers


I don't think there is any sure way to know if get_result() is required unless someone on the GAE team verifies this, but I think it's not needed. Here is how I tested it.

I wrote a simple handler:

class DB_TempTestModel(db.Model):
    data = db.BlobProperty()

class MyHandler(webapp.RequestHandler):
    def get(self):
        starttime = datetime.datetime.now()
        lots_of_data = ' '*500000
        if self.request.get('a') == '1':
            db.put(DB_TempTestModel(data=lots_of_data))
            db.put(DB_TempTestModel(data=lots_of_data))
            db.put(DB_TempTestModel(data=lots_of_data))
            db.put(DB_TempTestModel(data=lots_of_data))
        if self.request.get('a') == '2':
            db.put_async(DB_TempTestModel(data=lots_of_data))
            db.put_async(DB_TempTestModel(data=lots_of_data))
            db.put_async(DB_TempTestModel(data=lots_of_data))
            db.put_async(DB_TempTestModel(data=lots_of_data))
        self.response.out.write(str(datetime.datetime.now()-starttime))

I ran it a bunch of times on a High Replication Application.

The data was always there, making me believe that unless there is a failure in the datastore side of things (unlikely), it's gonna be written.

Here's the interesting part. When the data is written with put_async() (?a=2), the amount of time (to process the request) was on average about 2 to 3 times as fast as put()(?a=1) (not a very scientific test - just eyeballing it).

But the cpu_ms and api_cpu_ms were the same for both ?a=1 and ?a=2.

From the logs:

ms=440 cpu_ms=627 api_cpu_ms=580 cpm_usd=0.036244

vs

ms=149 cpu_ms=627 api_cpu_ms=580 cpm_usd=0.036244

On the client side, looking at the network latency of the requests, it showed the same results, i.e. `?a=2' requests were at least 2 times faster. Definitely a win on the client side... but it seems to not have any gain on the server side.

Anyone on the GAE team care to comment?


Need Your Help

Normal map from height map

opengl textures glsl shader hlsl

I am trying to create a normal map from a height map in HLSL. I followed this http://stackoverflow.com/a/5284527/451136 which is for GLSL. Here is how I translated GLSL to HLSL:

Fluorinefx Error Emailing

c# log4net fluorinefx

Has anyone ever set up error emailing with Fluorinefx?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.