diff -Nru python-requests-futures-0.9.5/debian/changelog python-requests-futures-0.9.7/debian/changelog --- python-requests-futures-0.9.5/debian/changelog 2015-09-20 09:22:30.000000000 +0000 +++ python-requests-futures-0.9.7/debian/changelog 2016-02-15 01:17:14.000000000 +0000 @@ -1,3 +1,13 @@ +python-requests-futures (0.9.7-1) unstable; urgency=medium + + * New upstream release. + * debian/control: + - Bump Standards-Version. + - Update Vcs-*. + * debian/copyright: Update copyright years. + + -- Sebastian Ramacher Mon, 15 Feb 2016 02:17:13 +0100 + python-requests-futures (0.9.5-2) unstable; urgency=medium * debian/python{,3}-requests-futures.docs: Include README.rst. (Closes: diff -Nru python-requests-futures-0.9.5/debian/control python-requests-futures-0.9.7/debian/control --- python-requests-futures-0.9.5/debian/control 2015-03-08 22:39:45.000000000 +0000 +++ python-requests-futures-0.9.7/debian/control 2016-02-15 01:15:23.000000000 +0000 @@ -15,8 +15,8 @@ X-Python3-Version: >= 3.2 Standards-Version: 3.9.6 Homepage: https://pypi.python.org/pypi/requests-futures -Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/python-requests-futures.git -Vcs-Git: git://anonscm.debian.org/collab-maint/python-requests-futures.git +Vcs-Browser: https://anonscm.debian.org/cgit/collab-maint/python-requests-futures.git +Vcs-Git: https://anonscm.debian.org/git/collab-maint/python-requests-futures.git Package: python-requests-futures Architecture: all diff -Nru python-requests-futures-0.9.5/debian/copyright python-requests-futures-0.9.7/debian/copyright --- python-requests-futures-0.9.5/debian/copyright 2015-03-08 22:39:45.000000000 +0000 +++ python-requests-futures-0.9.7/debian/copyright 2016-02-15 01:16:38.000000000 +0000 @@ -16,7 +16,7 @@ /usr/share/common-licenses/Apache-2.0 Files: debian/* -Copyright: 2015 Sebastian Ramacher +Copyright: 2015-2016 Sebastian Ramacher License: Expat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff -Nru python-requests-futures-0.9.5/MANIFEST.in python-requests-futures-0.9.7/MANIFEST.in --- python-requests-futures-0.9.5/MANIFEST.in 2013-04-08 15:29:18.000000000 +0000 +++ python-requests-futures-0.9.7/MANIFEST.in 2016-02-12 03:04:57.000000000 +0000 @@ -1 +1 @@ -include README.rst LICENSE test_requests_futures.py requirements-python-2.7.txt requirements-python-3.2.txt +include README.rst LICENSE test_requests_futures.py requirements-python-2.7.txt requirements-python-3.txt diff -Nru python-requests-futures-0.9.5/PKG-INFO python-requests-futures-0.9.7/PKG-INFO --- python-requests-futures-0.9.5/PKG-INFO 2014-09-23 13:38:53.000000000 +0000 +++ python-requests-futures-0.9.7/PKG-INFO 2016-02-12 03:06:30.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: requests-futures -Version: 0.9.5 +Version: 0.9.7 Summary: Asynchronous Python HTTP for Humans. Home-page: https://github.com/ross/requests-futures Author: Ross McFarland @@ -76,6 +76,15 @@ from requests_futures.sessions import FuturesSession session = FuturesSession(max_workers=10) + FutureSession will use an existing session object if supplied: + + .. code-block:: python + + from requests import session + from requests_futures.sessions import FuturesSession + my_session = session() + future_session = FuturesSession(session=my_session) + That's it. The api of requests.Session is preserved without any modifications beyond returning a Future rather than Response. As with all futures exceptions are shifted (thrown) to the future.result() call so try/except blocks should be @@ -123,9 +132,9 @@ Classifier: Natural Language :: English Classifier: License :: OSI Approved :: Apache Software License Classifier: Programming Language :: Python -Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.1 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 +Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 diff -Nru python-requests-futures-0.9.5/README.rst python-requests-futures-0.9.7/README.rst --- python-requests-futures-0.9.5/README.rst 2013-04-08 15:14:14.000000000 +0000 +++ python-requests-futures-0.9.7/README.rst 2016-02-12 03:04:57.000000000 +0000 @@ -68,6 +68,15 @@ from requests_futures.sessions import FuturesSession session = FuturesSession(max_workers=10) +FutureSession will use an existing session object if supplied: + +.. code-block:: python + + from requests import session + from requests_futures.sessions import FuturesSession + my_session = session() + future_session = FuturesSession(session=my_session) + That's it. The api of requests.Session is preserved without any modifications beyond returning a Future rather than Response. As with all futures exceptions are shifted (thrown) to the future.result() call so try/except blocks should be diff -Nru python-requests-futures-0.9.5/requests_futures/__init__.py python-requests-futures-0.9.7/requests_futures/__init__.py --- python-requests-futures-0.9.5/requests_futures/__init__.py 2014-09-23 13:38:10.000000000 +0000 +++ python-requests-futures-0.9.7/requests_futures/__init__.py 2016-02-12 03:05:47.000000000 +0000 @@ -9,15 +9,16 @@ """ +import logging + __title__ = 'requests-futures' -__version__ = '0.9.5' +__version__ = '0.9.7' __build__ = 0x000000 __author__ = 'Ross McFarland' __license__ = 'Apache 2.0' __copyright__ = 'Copyright 2013 Ross McFarland' # Set default logging handler to avoid "No handler found" warnings. -import logging try: # Python 2.7+ from logging import NullHandler except ImportError: diff -Nru python-requests-futures-0.9.5/requests_futures/sessions.py python-requests-futures-0.9.7/requests_futures/sessions.py --- python-requests-futures-0.9.5/requests_futures/sessions.py 2014-01-21 22:54:31.000000000 +0000 +++ python-requests-futures-0.9.7/requests_futures/sessions.py 2016-02-12 03:04:57.000000000 +0000 @@ -24,9 +24,11 @@ from requests import Session from requests.adapters import DEFAULT_POOLSIZE, HTTPAdapter + class FuturesSession(Session): - def __init__(self, executor=None, max_workers=2, *args, **kwargs): + def __init__(self, executor=None, max_workers=2, session=None, *args, + **kwargs): """Creates a FuturesSession Notes @@ -49,6 +51,7 @@ self.mount('http://', HTTPAdapter(**adapter_kwargs)) self.executor = executor + self.session = session def request(self, *args, **kwargs): """Maintains the existing api for Session.request. @@ -59,7 +62,10 @@ response in the background, e.g. call resp.json() so that json parsing happens in the background thread. """ - func = sup = super(FuturesSession, self).request + if self.session: + func = sup = self.session.request + else: + func = sup = super(FuturesSession, self).request background_callback = kwargs.pop('background_callback', None) if background_callback: @@ -71,3 +77,9 @@ func = wrap return self.executor.submit(func, *args, **kwargs) + + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + self.executor.shutdown() diff -Nru python-requests-futures-0.9.5/requests_futures.egg-info/PKG-INFO python-requests-futures-0.9.7/requests_futures.egg-info/PKG-INFO --- python-requests-futures-0.9.5/requests_futures.egg-info/PKG-INFO 2014-09-23 13:38:52.000000000 +0000 +++ python-requests-futures-0.9.7/requests_futures.egg-info/PKG-INFO 2016-02-12 03:06:30.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: requests-futures -Version: 0.9.5 +Version: 0.9.7 Summary: Asynchronous Python HTTP for Humans. Home-page: https://github.com/ross/requests-futures Author: Ross McFarland @@ -76,6 +76,15 @@ from requests_futures.sessions import FuturesSession session = FuturesSession(max_workers=10) + FutureSession will use an existing session object if supplied: + + .. code-block:: python + + from requests import session + from requests_futures.sessions import FuturesSession + my_session = session() + future_session = FuturesSession(session=my_session) + That's it. The api of requests.Session is preserved without any modifications beyond returning a Future rather than Response. As with all futures exceptions are shifted (thrown) to the future.result() call so try/except blocks should be @@ -123,9 +132,9 @@ Classifier: Natural Language :: English Classifier: License :: OSI Approved :: Apache Software License Classifier: Programming Language :: Python -Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.1 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 +Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 diff -Nru python-requests-futures-0.9.5/requests_futures.egg-info/requires.txt python-requests-futures-0.9.7/requests_futures.egg-info/requires.txt --- python-requests-futures-0.9.5/requests_futures.egg-info/requires.txt 2014-09-23 13:38:52.000000000 +0000 +++ python-requests-futures-0.9.7/requests_futures.egg-info/requires.txt 2016-02-12 03:06:30.000000000 +0000 @@ -1,2 +1,2 @@ requests>=1.2.0 -futures>=2.1.3 \ No newline at end of file +futures>=2.1.3 diff -Nru python-requests-futures-0.9.5/requests_futures.egg-info/SOURCES.txt python-requests-futures-0.9.7/requests_futures.egg-info/SOURCES.txt --- python-requests-futures-0.9.5/requests_futures.egg-info/SOURCES.txt 2014-09-23 13:38:53.000000000 +0000 +++ python-requests-futures-0.9.7/requests_futures.egg-info/SOURCES.txt 2016-02-12 03:06:30.000000000 +0000 @@ -2,7 +2,7 @@ MANIFEST.in README.rst requirements-python-2.7.txt -requirements-python-3.2.txt +requirements-python-3.txt setup.py test_requests_futures.py requests_futures/__init__.py diff -Nru python-requests-futures-0.9.5/requirements-python-3.2.txt python-requests-futures-0.9.7/requirements-python-3.2.txt --- python-requests-futures-0.9.5/requirements-python-3.2.txt 2013-06-27 21:24:09.000000000 +0000 +++ python-requests-futures-0.9.7/requirements-python-3.2.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -requests>=1.2.0 diff -Nru python-requests-futures-0.9.5/requirements-python-3.txt python-requests-futures-0.9.7/requirements-python-3.txt --- python-requests-futures-0.9.5/requirements-python-3.txt 1970-01-01 00:00:00.000000000 +0000 +++ python-requests-futures-0.9.7/requirements-python-3.txt 2016-02-12 03:04:57.000000000 +0000 @@ -0,0 +1 @@ +requests>=1.2.0 diff -Nru python-requests-futures-0.9.5/setup.py python-requests-futures-0.9.7/setup.py --- python-requests-futures-0.9.5/setup.py 2013-06-27 21:23:52.000000000 +0000 +++ python-requests-futures-0.9.7/setup.py 2016-02-12 03:04:57.000000000 +0000 @@ -46,11 +46,11 @@ 'Natural Language :: English', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.1', 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', ), ) diff -Nru python-requests-futures-0.9.5/test_requests_futures.py python-requests-futures-0.9.7/test_requests_futures.py --- python-requests-futures-0.9.5/test_requests_futures.py 2014-01-21 22:54:31.000000000 +0000 +++ python-requests-futures-0.9.7/test_requests_futures.py 2016-02-12 03:04:57.000000000 +0000 @@ -4,13 +4,14 @@ """Tests for Requests.""" from concurrent.futures import Future -from requests import Response +from requests import Response, session from os import environ from requests_futures.sessions import FuturesSession from unittest import TestCase, main HTTPBIN = environ.get('HTTPBIN_URL', 'http://httpbin.org/') + def httpbin(*suffix): """Returns url for HTTPBIN resource.""" return HTTPBIN + '/'.join(suffix) @@ -53,6 +54,18 @@ resp = future.result() self.assertEqual('boom', cm.exception.args[0]) + def test_supplied_session(self): + """ Tests the `session` keyword argument. """ + requests_session = session() + requests_session.headers['Foo'] = 'bar' + sess = FuturesSession(session=requests_session) + future = sess.get(httpbin('headers')) + self.assertIsInstance(future, Future) + resp = future.result() + self.assertIsInstance(resp, Response) + self.assertEqual(200, resp.status_code) + self.assertEqual(resp.json()['headers']['Foo'], 'bar') + def test_max_workers(self): """ Tests the `max_workers` shortcut. """ from concurrent.futures import ThreadPoolExecutor @@ -79,6 +92,30 @@ resp = future.result() self.assertEqual(404, resp.status_code) + def test_context(self): + + class FuturesSessionTestHelper(FuturesSession): + + def __init__(self, *args, **kwargs): + super(FuturesSessionTestHelper, self).__init__(*args, **kwargs) + self._exit_called = False + + def __exit__(self, *args, **kwargs): + self._exit_called = True + return super(FuturesSessionTestHelper, self).__exit__(*args, + **kwargs) + + passout = None + with FuturesSessionTestHelper() as sess: + passout = sess + future = sess.get(httpbin('get')) + self.assertIsInstance(future, Future) + resp = future.result() + self.assertIsInstance(resp, Response) + self.assertEqual(200, resp.status_code) + + self.assertTrue(passout._exit_called) + if __name__ == '__main__': main()