non-blocking google api

42 views
Skip to first unread message

aliane abdelouahab

unread,
Oct 18, 2012, 7:04:31 AM10/18/12
to Tornado Web Server
hi
my question is simple:
is there another version of google api, sadly this one
http://code.google.com/p/google-api-python-client/ uses httlib2 which
i guess is blocking, so i think the solution is to use
tornado.httpserver and rewrite the library to make it non-blocking?

here is sample code for those that dont know it yet:how to get product
prices using google shop api:

class GCompare(tornado.web.RequestHandler):
def get(self):
begin = time.time()
client = build('shopping', 'v1', developerKey='get a key from
google api')
ressource = client.products()
request = ressource.list(source='public', country='FR',
q=u'iphone 3gs')
t = request.execute()
for i in range(len(t["items"])):
print t["items"][i]["product"]["inventories"][0]["price"]
# return prices
print t["items"][0]["product"]["link"] # return links
print time.time() - begin

this is blocking, and will take a lot of time, even if it returns only
few results (compared to amazon api which returns 10 pages).

A. Jesse Jiryu Davis

unread,
Oct 19, 2012, 9:32:34 AM10/19/12
to python-...@googlegroups.com
Yes, to make it non-blocking you'll have to rewrite it to use AsyncHTTPClient instead of httplib.

aliane abdelouahab

unread,
Oct 19, 2012, 10:08:22 AM10/19/12
to Tornado Web Server
thank you :)
so the library must be rewrited! hope one guy from google lands here
and see the thread ;)

On 19 oct, 15:32, "A. Jesse Jiryu Davis" <ajesseda...@gmail.com>
wrote:
> Yes, to make it non-blocking you'll have to rewrite it to use
> AsyncHTTPClient instead of httplib.
>
>
>
>
>
>
>
> On Thursday, October 18, 2012 7:04:34 AM UTC-4, aliane abdelouahab wrote:
>
> > hi
> > my question is simple:
> > is there another version of google api, sadly this one
> >http://code.google.com/p/google-api-python-client/uses httlib2 which
Reply all
Reply to author
Forward
0 new messages