Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'NoneType' object has no attribute 'wrap_socket' in GAE

I am try to fetch some tweets in Google App Engine and doing some analysis on that tweets.

Due to some issue in urllib3, I am facing the following error :

AttributeError: 'NoneType' object has no attribute 'wrap_socket' 

The last three call are :

File         "/Users/krishna/Documents/DATASCI/twitterapi/analyzetweets/requests/packages/urllib3/connectionpool.py", line 304, in _make_request
self._validate_conn(conn)
File         "/Users/krishna/Documents/DATASCI/twitterapi/analyzetweets/requests/packages/urllib3/connectionpool.py", line 722, in _validate_conn
    conn.connect()
File "/Users/krishna/Documents/DATASCI/twitterapi/analyzetweets/requests/packages/urllib3/connection.py", line 164, in connect
self.sock = ssl.wrap_socket(conn, self.key_file, self.cert_file)
AttributeError: 'NoneType' object has no attribute 'wrap_socket'

Traceback (most recent call last):

INFO     2014-08-24 10:37:05,800 connectionpool.py:695] Starting new HTTPS connection (1): api.twitter.com
ERROR    2014-08-24 10:37:06,175 webapp2.py:1528] 'NoneType' object has no attribute 'wrap_socket'

Traceback (most recent call last):
File "/Users/krishna/google-cloud-sdk/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 1511, in __call__
    rv = self.handle_exception(request, response, e)
File "/Users/krishna/google-cloud-sdk/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 1505, in __call__
    rv = self.router.dispatch(request, response)
File "/Users/krishna/google-cloud-sdk/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
    return route.handler_adapter(request, response)
File "/Users/krishna/google-cloud-sdk/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 1077, in __call__
    return handler.dispatch()
File "/Users/krishna/google-cloud-sdk/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 547, in dispatch
    return self.handle_exception(e, self.app.debug)
File "/Users/krishna/google-cloud-sdk/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3/webapp2.py", line 545, in dispatch
    return method(*args, **kwargs)
File "/Users/krishna/Documents/DATASCI/twitterapi/analyzetweets/main.py", line 50, in post
    tweetTextCotainer = THandler.getTweetsText()
File "/Users/krishna/Documents/DATASCI/twitterapi/analyzetweets/main.py", line 82, in getTweetsText
    access_token_secret = self.access_token_secret
File     "/Users/krishna/Documents/DATASCI/twitterapi/analyzetweets/TwitterSearch/TwitterSearch.py",     line 63, in __init__
    self.authenticate(verify)
File "/Users/krishna/Documents/DATASCI/twitterapi/analyzetweets/TwitterSearch/TwitterSearch.py", line 83, in authenticate
    r = requests.get(self._base_url + self._verify_url, auth=self.__oauth,     proxies=self.__proxy)
File "/Users/krishna/Documents/DATASCI/twitterapi/analyzetweets/requests/api.py", line 55, in get
    return request('get', url, **kwargs)
File "/Users/krishna/Documents/DATASCI/twitterapi/analyzetweets/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
File "/Users/krishna/Documents/DATASCI/twitterapi/analyzetweets/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
File "/Users/krishna/Documents/DATASCI/twitterapi/analyzetweets/requests/sessions.py", line 574, in send
    r = adapter.send(request, **kwargs)
File "/Users/krishna/Documents/DATASCI/twitterapi/analyzetweets/requests/adapters.py", line 345, in send
    timeout=timeout
File "/Users/krishna/Documents/DATASCI/twitterapi/analyzetweets/requests/packages/urllib3/connectionpool.py", line 516, in urlopen
    body=body, headers=headers)
File     "/Users/krishna/Documents/DATASCI/twitterapi/analyzetweets/requests/packages/urllib3/connectionpool.py", line 304, in _make_request
    self._validate_conn(conn)
File     "/Users/krishna/Documents/DATASCI/twitterapi/analyzetweets/requests/packages/urllib3/connectionpool.py", line 722, in _validate_conn
    conn.connect()
File "/Users/krishna/Documents/DATASCI/twitterapi/analyzetweets/requests/packages/urllib3/connection.py", line 164, in connect
    self.sock = ssl.wrap_socket(conn, self.key_file, self.cert_file)
    AttributeError: 'NoneType' object has no attribute 'wrap_socket'
like image 286
krishna Prasad Avatar asked Oct 20 '22 02:10

krishna Prasad


1 Answers

For posterity (full discussion available on GitHub):

The "ssl" library appeared to have issues with import, thus ssl = None.

Updating the app.yaml helped.

libraries:
- name: ssl
  version: latest
like image 128
Jess Avatar answered Oct 23 '22 10:10

Jess