Skip to content

Instantly share code, notes, and snippets.

@PythonCoderAS
Created June 21, 2018 22:56
Show Gist options
  • Select an option

  • Save PythonCoderAS/e46b6ec7db7214dda93caaf1fd8cae46 to your computer and use it in GitHub Desktop.

Select an option

Save PythonCoderAS/e46b6ec7db7214dda93caaf1fd8cae46 to your computer and use it in GitHub Desktop.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
c:\program files\python36\lib\site-packages\urllib3\connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
376 try: # Python 2.7, use buffering of HTTP responses
--> 377 httplib_response = conn.getresponse(buffering=True)
378 except TypeError: # Python 2.6 and older, Python 3
TypeError: getresponse() got an unexpected keyword argument 'buffering'
During handling of the above exception, another exception occurred:
WantReadError Traceback (most recent call last)
c:\program files\python36\lib\site-packages\urllib3\contrib\pyopenssl.py in recv_into(self, *args, **kwargs)
284 try:
--> 285 return self.connection.recv_into(*args, **kwargs)
286 except OpenSSL.SSL.SysCallError as e:
c:\program files\python36\lib\site-packages\OpenSSL\SSL.py in recv_into(self, buffer, nbytes, flags)
1813 result = _lib.SSL_read(self._ssl, buf, nbytes)
-> 1814 self._raise_ssl_error(self._ssl, result)
1815
c:\program files\python36\lib\site-packages\OpenSSL\SSL.py in _raise_ssl_error(self, ssl, result)
1613 if error == _lib.SSL_ERROR_WANT_READ:
-> 1614 raise WantReadError()
1615 elif error == _lib.SSL_ERROR_WANT_WRITE:
WantReadError:
During handling of the above exception, another exception occurred:
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-35-03b5f561f094> in <module>()
----> 1 list(randomgen(1000))
<ipython-input-31-0ac2faf68751> in randomgen(amt)
1 def randomgen(amt):
2 for i in trange(amt):
----> 3 yield randomsub()
4
5
<ipython-input-18-0cd1727ec200> in randomsub()
1 def randomsub():
----> 2 s = r.subreddit('random')
3 return s.display_name
c:\program files\python36\lib\site-packages\praw\models\helpers.py in __call__(self, display_name)
158
159 if lower_name == 'random':
--> 160 return self._reddit.random_subreddit()
161 elif lower_name == 'randnsfw':
162 return self._reddit.random_subreddit(nsfw=True)
c:\program files\python36\lib\site-packages\praw\reddit.py in random_subreddit(self, nsfw)
457 path = None
458 try:
--> 459 self.get(url, params={'unique': self._next_unique})
460 except Redirect as redirect:
461 path = redirect.path
c:\program files\python36\lib\site-packages\praw\reddit.py in get(self, path, params)
369
370 """
--> 371 data = self.request('GET', path, params=params)
372 return self._objector.objectify(data)
373
c:\program files\python36\lib\site-packages\praw\reddit.py in request(self, method, path, params, data, files)
484 """
485 return self._core.request(method, path, data=data, files=files,
--> 486 params=params)
487
488 def submission( # pylint: disable=invalid-name,redefined-builtin
c:\program files\python36\lib\site-packages\prawcore\sessions.py in request(self, method, path, data, files, json, params)
180 return self._request_with_retries(
181 data=data, files=files, json=json, method=method,
--> 182 params=params, url=url)
183
184
c:\program files\python36\lib\site-packages\prawcore\sessions.py in _request_with_retries(self, data, files, json, method, params, url, retries)
111 self._log_request(data, method, params, url)
112 response, saved_exception = self._make_request(
--> 113 data, files, json, method, params, retries, url)
114
115 do_retry = False
c:\program files\python36\lib\site-packages\prawcore\sessions.py in _make_request(self, data, files, json, method, params, retries, url)
96 self._requestor.request, self._set_header_callback, method,
97 url, allow_redirects=False, data=data, files=files, json=json,
---> 98 params=params)
99 log.debug('Response: {} ({} bytes)'.format(
100 response.status_code, response.headers.get('content-length')))
c:\program files\python36\lib\site-packages\prawcore\rate_limit.py in call(self, request_function, set_header_callback, *args, **kwargs)
31 self.delay()
32 kwargs['headers'] = set_header_callback()
---> 33 response = request_function(*args, **kwargs)
34 self.update(response.headers)
35 return response
c:\program files\python36\lib\site-packages\prawcore\requestor.py in request(self, *args, **kwargs)
45 """Issue the HTTP request capturing any errors that may occur."""
46 try:
---> 47 return self._http.request(*args, timeout=TIMEOUT, **kwargs)
48 except Exception as exc:
49 raise RequestException(exc, args, kwargs)
c:\program files\python36\lib\site-packages\requests\sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
510 }
511 send_kwargs.update(settings)
--> 512 resp = self.send(prep, **send_kwargs)
513
514 return resp
c:\program files\python36\lib\site-packages\requests\sessions.py in send(self, request, **kwargs)
620
621 # Send the request
--> 622 r = adapter.send(request, **kwargs)
623
624 # Total elapsed time of the request (approximately)
c:\program files\python36\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
443 decode_content=False,
444 retries=self.max_retries,
--> 445 timeout=timeout
446 )
447
c:\program files\python36\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
598 timeout=timeout_obj,
599 body=body, headers=headers,
--> 600 chunked=chunked)
601
602 # If we're going to release the connection in ``finally:``, then
c:\program files\python36\lib\site-packages\urllib3\connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
378 except TypeError: # Python 2.6 and older, Python 3
379 try:
--> 380 httplib_response = conn.getresponse()
381 except Exception as e:
382 # Remove the TypeError from the exception chain in Python 3;
c:\program files\python36\lib\http\client.py in getresponse(self)
1329 try:
1330 try:
-> 1331 response.begin()
1332 except ConnectionError:
1333 self.close()
c:\program files\python36\lib\http\client.py in begin(self)
295 # read until we get a non-100 response
296 while True:
--> 297 version, status, reason = self._read_status()
298 if status != CONTINUE:
299 break
c:\program files\python36\lib\http\client.py in _read_status(self)
256
257 def _read_status(self):
--> 258 line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
259 if len(line) > _MAXLINE:
260 raise LineTooLong("status line")
c:\program files\python36\lib\socket.py in readinto(self, b)
584 while True:
585 try:
--> 586 return self._sock.recv_into(b)
587 except timeout:
588 self._timeout_occurred = True
c:\program files\python36\lib\site-packages\urllib3\contrib\pyopenssl.py in recv_into(self, *args, **kwargs)
295 raise
296 except OpenSSL.SSL.WantReadError:
--> 297 if not util.wait_for_read(self.socket, self.socket.gettimeout()):
298 raise timeout('The read operation timed out')
299 else:
c:\program files\python36\lib\site-packages\urllib3\util\wait.py in wait_for_read(sock, timeout)
144 Returns True if the socket is readable, or False if the timeout expired.
145 """
--> 146 return wait_for_socket(sock, read=True, timeout=timeout)
147
148
c:\program files\python36\lib\site-packages\urllib3\util\wait.py in select_wait_for_socket(sock, read, write, timeout)
84 # thing.)
85 fn = partial(select.select, rcheck, wcheck, wcheck)
---> 86 rready, wready, xready = _retry_on_intr(fn, timeout)
87 return bool(rready or wready or xready)
88
c:\program files\python36\lib\site-packages\urllib3\util\wait.py in _retry_on_intr(fn, timeout)
40 # Modern Python, that retries syscalls by default
41 def _retry_on_intr(fn, timeout):
---> 42 return fn(timeout)
43 else:
44 # Old and broken Pythons.
KeyboardInterrupt:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment