Python facebook sdk facebook call slow compared to command line hang

I am using facebook python Graph API. When I call put_object to write to the feed, it takes about 12-14 seconds to complete the call. When I run from the command line using curl with the same parameters, I get the answer back after 1.2 seconds.

I ran the profiler in python code and I see that it spends 99.5% of the time in socket.recv. I'm not sure if this is a problem with phdbook python sdk or something else.

I'm on python 2.6. I can see from facebook.py that it uses urllib.

    file = urllib.urlopen("https://graph.facebook.com/" + path + "?" +
                          urllib.urlencode(args), post_data)

Has anyone experienced a similar slowdown? Any suggestions would be highly appreciated.

+3
source share
2 answers

CURL , urllib urllib2. , pycurl ( C-), urllib - python, httplib.

, , Tornado, Tornado, .

, , urllib urllib2 . , , facebook/twitter/amazon ..

0

http--? Curl -, urllib , https-url (, https://graph.facebook.com) -.

, , Python vs C. C , , , 12-14 Python, .

curl , urllib , , pycurl . http://pycurl.sourceforge.net/

0

Source: https://habr.com/ru/post/1794996/


All Articles