Created
January 22, 2014 16:33
-
-
Save manugarri/8561995 to your computer and use it in GitHub Desktop.
Grequest Issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import grequests | |
CRUNCHBASE_API_KEY = 'asdasdasdasdadaasdasdasdas' | |
''' | |
base url to get a company's info. The individual company link loks like this: | |
http://ec2-107-21-104-179.compute-1.amazonaws.com/v/1/company/facebook.js | |
''' | |
base_url = 'http://api.crunchbase.com/v/1/company/%%s.js?api_key=%s' % API_KEY | |
#names is a list of company names parsed via the Crunchase API | |
names = ['Facebook', 'Linkedin', ...] | |
urls = [base_url % i for i in names] | |
rs = (grequests.get(u) for u in urls) | |
responses = grequests.imap(rs, size = 1000) | |
time.sleep(60) | |
'''And this is the error i get: | |
Traceback (most recent call last): | |
File "/home/manuel/anaconda/lib/python2.7/site-packages/gevent/greenlet.py", line 327, in run | |
result = self._run(*self.args, **self.kwargs) | |
File "/home/manuel/anaconda/lib/python2.7/site-packages/grequests.py", line 128, in send | |
return r.send(stream=stream) | |
File "/home/manuel/anaconda/lib/python2.7/site-packages/grequests.py", line 71, in send | |
self.url, **merged_kwargs) | |
File "/home/manuel/anaconda/lib/python2.7/site-packages/requests/sessions.py", line 383, in request | |
resp = self.send(prep, **send_kwargs) | |
File "/home/manuel/anaconda/lib/python2.7/site-packages/requests/sessions.py", line 486, in send | |
r = adapter.send(request, **kwargs) | |
File "/home/manuel/anaconda/lib/python2.7/site-packages/requests/adapters.py", line 382, in send | |
raise ConnectionError(e) | |
ConnectionError: HTTPConnectionPool(host='ec2-107-21-104-179.compute-1.amazonaws.com', port=80): Max retries exceeded with url: /v/1/company/Nakko%20%28Dead%20Lead%29.js (Caused by <class 'socket.error'>: [Errno 110] Connection timed out) | |
<Greenlet at 0x40b47d0: send(<grequests.AsyncRequest object at 0x6975610>)> failed with ConnectionError | |
Traceback (most recent call last): | |
File "test2.py", line 240, in <module> | |
DF = get_comp_info(NAMES) | |
File "test2.py", line 81, in get_comp_info | |
for company_request in chunk_responses: | |
File "/home/manuel/anaconda/lib/python2.7/site-packages/grequests.py", line 130, in imap | |
for r in pool.imap_unordered(send, requests): | |
File "/home/manuel/anaconda/lib/python2.7/site-packages/gevent/pool.py", line 221, in next | |
raise value.exc | |
requests.exceptions.ConnectionError: HTTPConnectionPool(host='ec2-107-21-104-179.compute-1.amazonaws.com', port=80): Max retries exceeded with url: /v/1/company/Nakko%20%28Dead%20Lead%29.js (Caused by <class 'socket.error'>: [Errno 110] Connection timed out) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment