Skip to content
Myr

updated urllib3

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 f5f2ddf · Browse files · 11 files+31 added−17 removed
This commit

State

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

Diff stats

11 files+31 added−17 removed

  • other:+31 added−17 removed

11 files+31 added−17 removed

modified:requests/packages/urllib3/contrib/__init__.py
modified:requests/packages/urllib3/contrib/ntlmpool.py
modified:requests/packages/urllib3/__init__.py+1 added-1 removed
8 unmodified lines
9"""1011__author__ = 'Andrey Petrov (andrey.petrov@shazow.net)'12__license__ = 'MIT'13__version__ = '1.0.1'13__version__ = '1.0.2'141516from .connectionpool import (17 HTTPConnectionPool,
31 unmodified lines
modified:requests/packages/urllib3/_collections.py+28 added-14 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 MutableMapping, deque7from collections import deque, MutableMapping89from threading import RLock1011__all__ = ['RecentlyUsedContainer']1213
10 unmodified lines
24 Provides a dict-like that maintains up to ``maxsize`` keys while throwing25 away the least-recently-used keys beyond ``maxsize``.26 """2727 # TODO: Make this threadsafe. _prune_invalidated_entries should be the28 # only real pain-point for this.2928 # 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 = 10
4 unmodified lines
36 self._container = {}3738 # 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()4142 # 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.
1 unmodified line
4647 # Trigger a heap cleanup when we get past this size48 self.access_log_limit = maxsize * self.CLEANUP_FACTOR4951 def _push_entry(self, key):52 "Push entry onto our access log, invalidate the old entry if exists."53 # Invalidate old entry if it exists50 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 = False5558 new_entry = AccessEntry(key)56 return old_entry5758 def _push_entry(self, key):59 "Push entry onto our access log, invalidate the old entry if exists."60 self._invalidate_entry(key)6162 new_entry = AccessEntry(key)63 self.access_lookup[key] = new_entry6465 self.access_log_lock.acquire()66 self.access_log.appendleft(new_entry)67 self.access_log_lock.release()6869 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()7576 if not p.is_valid:77 continue # Invalidated entry, skip7871 del self._container[p.key]72 del self.access_lookup[p.key]79 self._container.pop(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):80 # Used for testing81 return [e.key for e in self.access_log if e.is_valid]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 = self._container.get(key)99100 if not item:87 return101 raise KeyError(key)102103 # Insert new entry with new high priority, also implicitly invalidates104 # the old entry.105 self._push_entry(key)
15 unmodified lines
121122 def __delitem__(self, key):123 self._invalidate_entry(key)124 del self._container[key]111 del self._access_lookup[key]125 del self.access_lookup[key]126127 def __len__(self):128 return self._container.__len__()129
5 unmodified lines
modified:requests/packages/urllib3/connectionpool.py
modified:requests/packages/urllib3/exceptions.py
modified:requests/packages/urllib3/filepost.py
modified:requests/packages/urllib3/poolmanager.py+1 added-1 removed
106 unmodified lines
107 conn = self.connection_from_url(url)108 return conn.urlopen(method, url, assert_same_host=False, **kw)109110111class ProxyManager(object):111class ProxyManager(RequestMethods):112 """113 Given a ConnectionPool to a proxy, the ProxyManager's ``urlopen`` method114 will make requests to any url through the defined proxy.115 """
13 unmodified lines
modified:requests/packages/urllib3/request.py
modified:requests/packages/urllib3/response.py
modified:requests/packages/__init__.py+1 added-1 removed
1from __future__ import absolute_import23from . import poster3from . import urllib3