Skip to content
Myr

urllib update and junks

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 0d9ab27 · Browse files · 7 files+322 added−214 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+322 added−214 removed

  • other:+322 added−214 removed

7 files+322 added−214 removed

modified:requests/packages/urllib3/_collections.py+64 added-101 removed
2 unmodified lines
3#4# This module is part of urllib3 and is released under5# the MIT License: http://www.opensource.org/licenses/mit-license.php67from collections import deque7from collections import MutableMapping8from threading import Lock99from threading import RLock10try: # Python 2.7+11 from collections import OrderedDict12except ImportError:13 from .packages.ordered_dict import OrderedDict141516__all__ = ['RecentlyUsedContainer']171814class AccessEntry(object):15 __slots__ = ('key', 'is_valid')19_Null = object()2017 def __init__(self, key, is_valid=True):18 self.key = key19 self.is_valid = is_valid2122class RecentlyUsedContainer(MutableMapping):23 """24 Provides a thread-safe dict-like container which maintains up to25 ``maxsize`` keys while throwing away the least-recently-used keys beyond26 ``maxsize``.2722class RecentlyUsedContainer(dict):28 :param maxsize:29 Maximum number of recent elements to retain.3031 :param dispose_func:32 Every time an item is evicted from the container,33 ``dispose_func(value)`` is called. Callback which will get called34 """24 Provides a dict-like that maintains up to ``maxsize`` keys while throwing25 away the least-recently-used keys beyond ``maxsize``.26 """3528 # If len(self.access_log) exceeds self._maxsize * CLEANUP_FACTOR, then we29 # will attempt to cleanup the invalidated entries in the access_log30 # datastructure during the next 'get' operation.31 CLEANUP_FACTOR = 1036 ContainerCls = OrderedDict3733 def __init__(self, maxsize=10):38 def __init__(self, maxsize=10, dispose_func=None):39 self._maxsize = maxsize40 self.dispose_func = dispose_func4136 self._container = {}42 self._container = self.ContainerCls()43 self._lock = Lock()4438 # We use a deque to to store our keys ordered by the last access.39 self.access_log = deque()40 self.access_log_lock = RLock()45 def __getitem__(self, key):46 # Re-insert the item, moving it to the end of the eviction line.47 with self._lock:48 item = self._container.pop(key)49 self._container[key] = item50 return item5142 # We look up the access log entry by the key to invalidate it so we can43 # insert a new authorative entry at the head without having to dig and44 # find the old entry for removal immediately.45 self.access_lookup = {}52 def __setitem__(self, key, value):53 evicted_value = _Null54 with self._lock:55 # Possibly evict the existing value of 'key'56 evicted_value = self._container.get(key, _Null)57 self._container[key] = value5847 # Trigger a heap cleanup when we get past this size48 self.access_log_limit = maxsize * self.CLEANUP_FACTOR59 # If we didn't evict an existing value, we might have to evict the60 # least recently used item from the beginning of the container.61 if len(self._container) > self._maxsize:62 _key, evicted_value = self._container.popitem(last=False)6350 def _invalidate_entry(self, key):51 "If exists: Invalidate old entry and return it."52 old_entry = self.access_lookup.get(key)53 if old_entry:54 old_entry.is_valid = False64 if self.dispose_func and evicted_value is not _Null:65 self.dispose_func(evicted_value)6656 return old_entry67 def __delitem__(self, key):68 with self._lock:69 value = self._container.pop(key)7058 def _push_entry(self, key):59 "Push entry onto our access log, invalidate the old entry if exists."60 self._invalidate_entry(key)71 if self.dispose_func:72 self.dispose_func(value)7362 new_entry = AccessEntry(key)63 self.access_lookup[key] = new_entry74 def __len__(self):75 with self._lock:76 return len(self._container)7765 self.access_log_lock.acquire()66 self.access_log.appendleft(new_entry)67 self.access_log_lock.release()78 def __iter__(self):79 raise NotImplementedError('Iteration over this class is unlikely to be threadsafe.')8069 def _prune_entries(self, num):70 "Pop entries from our access log until we popped ``num`` valid ones."71 while num > 0:72 self.access_log_lock.acquire()73 p = self.access_log.pop()74 self.access_log_lock.release()81 def clear(self):82 with self._lock:83 # Copy pointers to all values, then wipe the mapping84 # under Python 2, this copies the list of values twice :-|85 values = list(self._container.values())86 self._container.clear()8776 if not p.is_valid:77 continue # Invalidated entry, skip88 if self.dispose_func:89 for value in values:90 self.dispose_func(value)9179 dict.pop(self, p.key, None)80 self.access_lookup.pop(p.key, None)81 num -= 18283 def _prune_invalidated_entries(self):84 "Rebuild our access_log without the invalidated entries."85 self.access_log_lock.acquire()86 self.access_log = deque(e for e in self.access_log if e.is_valid)87 self.access_log_lock.release()8889 def _get_ordered_access_keys(self):90 "Return ordered access keys for inspection. Used for testing."91 self.access_log_lock.acquire()92 r = [e.key for e in self.access_log if e.is_valid]93 self.access_log_lock.release()9495 return r9697 def __getitem__(self, key):98 item = dict.get(self, key)99100 if not item:101 raise KeyError(key)102103 # Insert new entry with new high priority, also implicitly invalidates104 # the old entry.105 self._push_entry(key)106107 if len(self.access_log) > self.access_log_limit:108 # Heap is getting too big, try to clean up any tailing invalidated109 # entries.110 self._prune_invalidated_entries()111112 return item113114 def __setitem__(self, key, item):115 # Add item to our container and access log116 dict.__setitem__(self, key, item)117 self._push_entry(key)118119 # Discard invalid and excess entries120 self._prune_entries(len(self) - self._maxsize)121122 def __delitem__(self, key):123 self._invalidate_entry(key)124 self.access_lookup.pop(key, None)125 dict.__delitem__(self, key)126127 def get(self, key, default=None):128 try:129 return self[key]130 except KeyError:131 return default92 def keys(self):93 with self._lock:94 return self._container.keys()
modified:requests/packages/urllib3/connectionpool.py+59 added-22 removed
5 unmodified lines
67import logging8import socket910from socket import error as SocketError, timeout as SocketTimeout10from socket import timeout as SocketTimeout1112try: # Python 312try: # Python 313 from http.client import HTTPConnection, HTTPException14 from http.client import HTTP_PORT, HTTPS_PORT15except ImportError:16 from httplib import HTTPConnection, HTTPException17 from httplib import HTTP_PORT, HTTPS_PORT1819try: # Python 319try: # Python 320 from queue import LifoQueue, Empty, Full21except ImportError:22 from Queue import LifoQueue, Empty, Full232425try: # Compiled with SSL?25try: # Compiled with SSL?26 HTTPSConnection = object27 BaseSSLError = None28 ssl = None2930 try: # Python 330 try: # Python 331 from http.client import HTTPSConnection32 except ImportError:33 from httplib import HTTPSConnection3435 import ssl36 BaseSSLError = ssl.SSLError3738except (ImportError, AttributeError):38except (ImportError, AttributeError): # Platform-specific: No SSL.39 pass404142from .request import RequestMethods43from .response import HTTPResponse44from .util import get_host, is_connection_dropped45from .exceptions import (46 ClosedPoolError,47 EmptyPoolError,48 HostChangedError,49 MaxRetryError,50 SSLError,
155 unmodified lines
206 conn = None207 try:208 conn = self.pool.get(block=self.block, timeout=timeout)209209 # If this is a persistent connection, check if it got disconnected210 if conn and is_connection_dropped(conn):211 log.info("Resetting dropped connection: %s" % self.host)212 conn.close()210 except AttributeError: # self.pool is None211 raise ClosedPoolError(self, "Pool is closed.")212213 except Empty:214 if self.block:215 raise EmptyPoolError(self,216 "Pool reached maximum size and no more "217 "connections are allowed.")218 pass # Oh well, we'll create a new connection then219220 # If this is a persistent connection, check if it got disconnected221 if conn and is_connection_dropped(conn):222 log.info("Resetting dropped connection: %s" % self.host)223 conn.close()224225 return conn or self._new_conn()226227 def _put_conn(self, conn):228 """
2 unmodified lines
231 :param conn:232 Connection object for the current host and port as returned by233 :meth:`._new_conn` or :meth:`._get_conn`.234231 If the pool is already full, the connection is discarded because we232 exceeded maxsize. If connections are discarded frequently, then maxsize233 should be increased.235 If the pool is already full, the connection is closed and discarded236 because we exceeded maxsize. If connections are discarded frequently,237 then maxsize should be increased.238239 If the pool is closed, then the connection will be closed and discarded.240 """241 try:242 self.pool.put(conn, block=False)243 return # Everything is dandy, done.244 except AttributeError:245 # self.pool is None.246 pass247 except Full:248 # This should never happen if self.block == True249 log.warning("HttpConnectionPool is full, discarding connection: %s"250 % self.host)251252 # Connection never got put back into the pool, close it.253 conn.close()254255 def _make_request(self, conn, method, url, timeout=_Default,256 **httplib_request_kw):257 """258 Perform a request on a given httplib connection object taken from our
21 unmodified lines
280 http_version = getattr(conn, '_http_vsn_str', 'HTTP/?')281 log.debug("\"%s %s %s\" %s %s" % (method, url, http_version,282 httplib_response.status,283 httplib_response.length))271284 return httplib_response285286 def close(self):287 """288 Close all pooled connections and disable the pool.289 """290 # Disable access to the pool291 old_pool, self.pool = self.pool, None292293 try:294 while True:295 conn = old_pool.get(block=False)296 if conn:297 conn.close()298299 except Empty:300 pass # Done.301302 def is_same_host(self, url):303 """304 Check if the given ``url`` is a member of the same host as this305 connection pool.306 """307 if url.startswith('/'):308 return True309310 # TODO: Add optional support for socket.gethostbyname checking.311 scheme, host, port = get_host(url)312313 if self.port and not port:314 # Use explicit default port for comparison when none is given.315 port = port_by_scheme.get(scheme)316287 return (url.startswith('/') or288 (scheme, host, port) == (self.scheme, self.host, self.port))317 return (scheme, host, port) == (self.scheme, self.host, self.port)318319 def urlopen(self, method, url, body=None, headers=None, retries=3,320 redirect=True, assert_same_host=True, timeout=_Default,321 pool_timeout=None, release_conn=None, **response_kw):
84 unmodified lines
406 conn = None407408 try:409 # Request a connection from the queue381 # (Could raise SocketError: Bad file descriptor)410 conn = self._get_conn(timeout=pool_timeout)411412 # Make the request on the httplib connection object413 httplib_response = self._make_request(conn, method, url,
34 unmodified lines
448 except CertificateError as e:449 # Name mismatch450 raise SSLError(e)451424 except (HTTPException, SocketError) as e:452 except HTTPException as e:453 # Connection broken, discard. It will be replaced next _get_conn().454 conn = None455 # This is necessary so we can access e below456 err = e457458 finally:431 if conn and release_conn:432 # Put the connection back to be reused459 if release_conn:460 # Put the connection back to be reused. If the connection is461 # expired then it will be None, which will get replaced with a462 # fresh connection during _get_conn.463 self._put_conn(conn)464465 if not conn:466 # Try again467 log.warn("Retrying (%d attempts remain) after connection "468 "broken by '%r': %s" % (retries, err, url))469 return self.urlopen(method, url, body, headers, retries - 1,439 redirect, assert_same_host) # Try again470 redirect, assert_same_host,471 timeout=timeout, pool_timeout=pool_timeout,472 release_conn=release_conn, **response_kw)473474 # Handle redirect?475 redirect_location = redirect and response.get_redirect_location()476 if redirect_location:477 if response.status == 303:478 method = 'GET'479 log.info("Redirecting %s -> %s" % (url, redirect_location))480 return self.urlopen(method, redirect_location, body, headers,446 retries - 1, redirect, assert_same_host)481 retries - 1, redirect, assert_same_host,482 timeout=timeout, pool_timeout=pool_timeout,483 release_conn=release_conn, **response_kw)484485 return response486487
75 unmodified lines
modified:requests/packages/urllib3/exceptions.py+10 added
22 unmodified lines
23 "Raised when SSL certificate fails in an HTTPS connection."24 pass252627class DecodeError(HTTPError):28 "Raised when automatic decoding based on Content-Type fails."29 pass303132## Leaf Exceptions3334class MaxRetryError(PoolError):35 "Raised when the maximum number of retries is exceeded."
25 unmodified lines
61 "Raised when a pool runs out of connections and no more are allowed."62 pass636465class ClosedPoolError(PoolError):66 "Raised when a request enters a pool after the pool has been closed."67 pass686970class LocationParseError(ValueError, HTTPError):71 "Raised when get_host or similar fails to parse the URL input."7273 def __init__(self, location):
4 unmodified lines
modified:requests/packages/urllib3/poolmanager.py+42 added-22 removed
6 unmodified lines
7import logging89from ._collections import RecentlyUsedContainer10from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool11from .connectionpool import get_host, connection_from_url, port_by_scheme12from .exceptions import HostChangedError11from .connectionpool import connection_from_url, port_by_scheme12from .request import RequestMethods13from .util import parse_url141516__all__ = ['PoolManager', 'ProxyManager', 'proxy_from_url']17
29 unmodified lines
47 24849 """5051 # TODO: Make sure there are no memory leaks here.5251 def __init__(self, num_pools=10, **connection_pool_kw):52 self.connection_pool_kw = connection_pool_kw55 self.pools = RecentlyUsedContainer(num_pools)53 self.pools = RecentlyUsedContainer(num_pools,54 dispose_func=lambda p: p.close())5557 def connection_from_host(self, host, port=80, scheme='http'):56 def clear(self):57 """58 Empty our store of pools and direct them all to close.5960 This will not affect in-flight connections, but they will not be61 re-used after completion.62 """63 self.pools.clear()6465 def connection_from_host(self, host, port=None, scheme='http'):66 """67 Get a :class:`ConnectionPool` based on the host, port, and scheme.6861 Note that an appropriate ``port`` value is required here to normalize62 connection pools in our container most effectively.69 If ``port`` isn't given, it will be derived from the ``scheme`` using70 ``urllib3.connectionpool.port_by_scheme``.71 """72 port = port or port_by_scheme.get(scheme, 80)7374 pool_key = (scheme, host, port)7576 # If the scheme, host, or port doesn't match existing open connections,77 # open a new ConnectionPool.
17 unmodified lines
9596 Additional parameters are taken from the :class:`.PoolManager`97 constructor.98 """89 scheme, host, port = get_host(url)99 u = parse_url(url)100 return self.connection_from_host(u.host, port=u.port, scheme=u.scheme)10191 port = port or port_by_scheme.get(scheme, 80)9293 return self.connection_from_host(host, port=port, scheme=scheme)9495 def urlopen(self, method, url, **kw):102 def urlopen(self, method, url, redirect=True, **kw):103 """97 Same as :meth:`urllib3.connectionpool.HTTPConnectionPool.urlopen`.104 Same as :meth:`urllib3.connectionpool.HTTPConnectionPool.urlopen`105 with custom cross-host redirect logic and only sends the request-uri106 portion of the ``url``.10799 ``url`` must be absolute, such that an appropriate108 The given ``url`` parameter must be absolute, such that an appropriate109 :class:`urllib3.connectionpool.ConnectionPool` can be chosen for it.110 """102 conn = self.connection_from_url(url)103 try:104 return conn.urlopen(method, url, **kw)111 u = parse_url(url)112 conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme)113106 except HostChangedError as e:107 kw['retries'] = e.retries # Persist retries countdown108 return self.urlopen(method, e.url, **kw)114 kw['assert_same_host'] = False115 kw['redirect'] = False116117 response = conn.urlopen(method, u.request_uri, **kw)118119 redirect_location = redirect and response.get_redirect_location()120 if not redirect_location:121 return response122123 if response.status == 303:124 method = 'GET'125126 log.info("Redirecting %s -> %s" % (url, redirect_location))127 kw['retries'] = kw.get('retries', 3) - 1 # Persist retries countdown128 return self.urlopen(method, redirect_location, **kw)129130131class ProxyManager(RequestMethods):132 """133 Given a ConnectionPool to a proxy, the ProxyManager's ``urlopen`` method134 will make requests to any url through the defined proxy.
24 unmodified lines
modified:requests/packages/urllib3/response.py+4 added-4 removed
8 unmodified lines
9import zlib1011from io import BytesIO1213from .exceptions import HTTPError13from .exceptions import DecodeError14from .packages.six import string_types as basestring151617log = logging.getLogger(__name__)
129 unmodified lines
147148 try:149 if decode_content and decoder:150 data = decoder(data)151 except IOError:152 raise HTTPError("Received response with content-encoding: %s, but "153 "failed to decode it." % content_encoding)151 except (IOError, zlib.error):152 raise DecodeError("Received response with content-encoding: %s, but "153 "failed to decode it." % content_encoding)154155 if cache_content:156 self._body = data157
45 unmodified lines
modified:requests/packages/urllib3/util.py+135 added-65 removed
4 unmodified lines
5# the MIT License: http://www.opensource.org/licenses/mit-license.php678from base64 import b64encode9from collections import namedtuple10from socket import error as SocketError1112try:13 from select import poll, POLLIN14except ImportError: # `poll` doesn't exist on OSX and other platforms
6 unmodified lines
21from .packages import six22from .exceptions import LocationParseError232423def make_headers(keep_alive=None, accept_encoding=None, user_agent=None,24 basic_auth=None):25class Url(namedtuple('Url', ['scheme', 'auth', 'host', 'port', 'path', 'query', 'fragment'])):26 """26 Shortcuts for generating request headers.2728 :param keep_alive:29 If ``True``, adds 'connection: keep-alive' header.3031 :param accept_encoding:32 Can be a boolean, list, or string.33 ``True`` translates to 'gzip,deflate'.34 List will get joined by comma.35 String will be used as provided.3637 :param user_agent:38 String representing the user-agent you want, such as39 "python-urllib3/0.6"4041 :param basic_auth:42 Colon-separated username:password string for 'authorization: basic ...'43 auth header.4445 Example: ::4647 >>> make_headers(keep_alive=True, user_agent="Batman/1.0")48 {'connection': 'keep-alive', 'user-agent': 'Batman/1.0'}49 >>> make_headers(accept_encoding=True)50 {'accept-encoding': 'gzip,deflate'}27 Datastructure for representing an HTTP URL. Used as a return value for28 :func:`parse_url`.29 """52 headers = {}53 if accept_encoding:54 if isinstance(accept_encoding, str):55 pass56 elif isinstance(accept_encoding, list):57 accept_encoding = ','.join(accept_encoding)58 else:59 accept_encoding = 'gzip,deflate'60 headers['accept-encoding'] = accept_encoding30 slots = ()3162 if user_agent:63 headers['user-agent'] = user_agent32 def __new__(cls, scheme=None, auth=None, host=None, port=None, path=None, query=None, fragment=None):33 return super(Url, cls).__new__(cls, scheme, auth, host, port, path, query, fragment)3465 if keep_alive:66 headers['connection'] = 'keep-alive'35 @property36 def hostname(self):37 """For backwards-compatibility with urlparse. We're nice like that."""38 return self.host3968 if basic_auth:69 headers['authorization'] = 'Basic ' + \70 b64encode(six.b(basic_auth)).decode('utf-8')40 @property41 def request_uri(self):42 """Absolute path including the query string."""43 uri = self.path or '/'4472 return headers45 if self.query is not None:46 uri += '?' + self.query4748 return uri495051def split_first(s, delims):52 """53 Given a string and an iterable of delimiters, split on the first found78 delimiter. Return two split parts.54 delimiter. Return two split parts and the matched delimiter.5556 If not found, then the first part is the full input string.5758 Example: ::5960 >>> split_first('foo/bar?baz', '?/=')61 ('foo', 'bar?baz', '/')62 >>> split_first('foo/bar?baz', '123')63 ('foo/bar?baz', '', None)6465 Scales linearly with number of delims. Not ideal for large number of delims.66 """67 min_idx = None68 min_delim = None69 for d in delims:70 idx = s.find(d)71 if idx < 0:72 continue7390 if not min_idx:74 if min_idx is None or idx < min_idx:75 min_idx = idx92 else:93 min_idx = min(idx, min_idx)76 min_delim = d7795 if min_idx < 0:96 return s, ''78 if min_idx is None or min_idx < 0:79 return s, '', None8098 return s[:min_idx], s[min_idx+1:]81 return s[:min_idx], s[min_idx+1:], min_delim8283101def get_host(url):84def parse_url(url):85 """103 Given a url, return its scheme, host and port (None if it's not there).86 Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is87 performed to parse incomplete urls. Fields not provided will be None.88105 For example: ::89 Partly backwards-compatible with :mod:`urlparse`.90107 >>> get_host('http://google.com/mail/')108 ('http', 'google.com', None)109 >>> get_host('google.com:80')110 ('http', 'google.com', 80)91 Example: ::9293 >>> parse_url('http://google.com/mail/')94 Url(scheme='http', host='google.com', port=None, path='/', ...)95 >>> prase_url('google.com:80')96 Url(scheme=None, host='google.com', port=80, path=None, ...)97 >>> prase_url('/foo?bar')98 Url(scheme=None, host=None, port=None, path='/foo', query='bar', ...)99 """100101 # While this code has overlap with stdlib's urlparse, it is much102 # simplified for our needs and less annoying.103 # Additionally, this imeplementations does silly things to be optimal104 # on CPython.105118 scheme = 'http'106 scheme = None107 auth = None108 host = None109 port = None110 path = None111 fragment = None112 query = None113114 # Scheme115 if '://' in url:116 scheme, url = url.split('://', 1)117118 # Find the earliest Authority Terminator119 # (http://tools.ietf.org/html/rfc3986#section-3.2)128 url, _path = split_first(url, ['/', '?', '#'])120 url, path_, delim = split_first(url, ['/', '?', '#'])121122 if delim:123 # Reassemble the path124 path = delim + path_125126 # Auth127 if '@' in url:132 _auth, url = url.split('@', 1)128 auth, url = url.split('@', 1)129130 # IPv6131 if url and url[0] == '[':132 host, url = url[1:].split(']', 1)
9 unmodified lines
142 raise LocationParseError("Failed to parse: %s" % url)143144 port = int(port)145150 elif not host:146 elif not host and url:147 host = url148153 return scheme, host, port149 if not path:150 return Url(scheme, auth, host, port, path, query, fragment)151152 # Fragment153 if '#' in path:154 path, fragment = path.split('#', 1)155156 # Query157 if '?' in path:158 path, query = path.split('?', 1)159160 return Url(scheme, auth, host, port, path, query, fragment)161162163def get_host(url):164 """165 Deprecated. Use :func:`.parse_url` instead.166 """167 p = parse_url(url)168 return p.scheme or 'http', p.hostname, p.port169170171def make_headers(keep_alive=None, accept_encoding=None, user_agent=None,172 basic_auth=None):173 """174 Shortcuts for generating request headers.175176 :param keep_alive:177 If ``True``, adds 'connection: keep-alive' header.178179 :param accept_encoding:180 Can be a boolean, list, or string.181 ``True`` translates to 'gzip,deflate'.182 List will get joined by comma.183 String will be used as provided.184185 :param user_agent:186 String representing the user-agent you want, such as187 "python-urllib3/0.6"188189 :param basic_auth:190 Colon-separated username:password string for 'authorization: basic ...'191 auth header.192193 Example: ::194195 >>> make_headers(keep_alive=True, user_agent="Batman/1.0")196 {'connection': 'keep-alive', 'user-agent': 'Batman/1.0'}197 >>> make_headers(accept_encoding=True)198 {'accept-encoding': 'gzip,deflate'}199 """200 headers = {}201 if accept_encoding:202 if isinstance(accept_encoding, str):203 pass204 elif isinstance(accept_encoding, list):205 accept_encoding = ','.join(accept_encoding)206 else:207 accept_encoding = 'gzip,deflate'208 headers['accept-encoding'] = accept_encoding209210 if user_agent:211 headers['user-agent'] = user_agent212213 if keep_alive:214 headers['connection'] = 'keep-alive'215216 if basic_auth:217 headers['authorization'] = 'Basic ' + \218 b64encode(six.b(basic_auth)).decode('utf-8')219220 return headers221222223def is_connection_dropped(conn):224 """225 Returns True if the connection is dropped and should be closed.226227 :param conn:161 ``HTTPConnection`` object.228 :class:`httplib.HTTPConnection` object.229230 Note: For platforms like AppEngine, this will always return ``False`` to231 let the platform handle connection recycling transparently for us.232 """
4 unmodified lines
237 if not poll: # Platform-specific238 if not select: # Platform-specific: AppEngine239 return False240241 try:174 return select([sock], [], [], 0.0)[0]242 return select([sock], [], [], 0.0)[0]243 except SocketError:244 return True245246 # This version is better on platforms that support it.247 p = poll()248 p.register(sock, POLLIN)
4 unmodified lines
modified:HISTORY.rst+8 added
1 unmodified line
23History4-------560.13.4 (2012-xx-xx)7+++++++++++++++++++89- Fix leaking connections (from urllib3 update)10- OAuthlib path hack fi11- App Engine 2.7 Fixes!1213140.13.3 (2012-07-12)15+++++++++++++++++++1617- Use simplejson if available.
493 unmodified lines