{ "info": { "author": "Pierre Tardy", "author_email": "tardyp@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7" ], "description": "Asynchronous Python HTTP Requests for Humans\n============================================\n\n.. image:: https://travis-ci.org/tardyp/txrequests.png?branch=master\n :target: https://travis-ci.org/tardyp/txrequests\n\nSmall add-on for the python requests_ http library. Makes use twisted's ThreadPool,\nso that the requests'API returns deferred\n\nThe additional API and changes are minimal and strives to avoid surprises.\n\nThe following synchronous code:\n\n.. code-block:: python\n\n from requests import Session\n\n session = Session()\n # first requests starts and blocks until finished\n response_one = session.get('http://httpbin.org/get')\n # second request starts once first is finished\n response_two = session.get('http://httpbin.org/get?foo=bar')\n # both requests are complete\n print('response one status: {0}'.format(response_one.status_code))\n print(response_one.content)\n print('response two status: {0}'.format(response_two.status_code))\n print(response_two.content)\n\nCan be translated to make use of futures, and thus be asynchronous by creating\na FuturesSession and catching the returned Future in place of Response. The\nResponse can be retrieved by calling the result method on the Future:\n\n.. code-block:: python\n\n from txrequests import Session\n from twisted.internet import defer\n\n @defer.inlineCallbacks\n def main():\n # use with statement to cleanup session's threadpool, and connectionpool after use\n # you can also use session.close() if want to use session for long term use\n with Session() as session:\n # first request is started in background\n d1 = session.get('http://httpbin.org/get')\n # second requests is started immediately\n d2 = session.get('http://httpbin.org/get?foo=bar')\n # wait for the first request to complete, if it hasn't already\n response_one = yield d1\n print('response one status: {0}'.format(response_one.status_code))\n print(response_one.content)\n # wait for the second request to complete, if it hasn't already\n response_two = yield d2\n print('response two status: {0}'.format(response_two.status_code))\n print(response_two.content)\n\nBy default a ThreadPool is created with 4 max workers. If you would like to\nadjust that value or share a threadpool across multiple sessions you can provide\none to the Session constructor.\n\n.. code-block:: python\n\n from twisted.python.threadpool import ThreadPool\n from txrequests import Session\n\n session = FuturesSession(pool=ThreadPool(maxthreads=10))\n # ...\n\nAs a shortcut in case of just increasing workers number you can pass\n`minthreads` and/or `maxthreads` straight to the `Session` constructor:\n\n.. code-block:: python\n\n from txrequests import Session\n session = Session(maxthreads=10)\n\nThat's it. The api of requests.Session is preserved without any modifications\nbeyond returning a Deferred rather than Response. As with all futures exceptions\nare shifted to the deferred errback.\n\nWorking in the Background\n=========================\n\nThere is one additional parameter to the various request functions,\nbackground_callback, which allows you to work with the Response objects in the\nbackground thread. This can be useful for shifting work out of the foreground,\nfor a simple example take json parsing.\n\n.. code-block:: python\n\n from pprint import pprint\n from txrequests import Session\n from twisted.internet import defer\n\n @defer.inlineCallbacks\n def main():\n with Session() as session:\n\n def bg_cb(sess, resp):\n # parse the json storing the result on the response object\n resp.data = resp.json()\n return resp\n\n d = session.get('http://httpbin.org/get', background_callback=bg_cb)\n # do some other stuff, send some more requests while this one works\n response = yield d\n print('response status {0}'.format(response.status_code))\n # data will have been attached to the response object in the background\n pprint(response.data)\n\nInstallation\n============\n\n pip install txrequests\n\n\nCredits\n========\n\ntxrequests is based on requests_future_, from Ross McFarland\n\n.. _`requests`: https://github.com/kennethreitz/requests\n.. _`requests_future`: https://github.com/ross/requests-futures\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tardyp/txrequests", "keywords": "", "license": "Apache License v2", "maintainer": "", "maintainer_email": "", "name": "txrequests", "package_url": "https://pypi.org/project/txrequests/", "platform": "", "project_url": "https://pypi.org/project/txrequests/", "project_urls": { "Homepage": "https://github.com/tardyp/txrequests" }, "release_url": "https://pypi.org/project/txrequests/0.9.6/", "requires_dist": [ "requests (>=1.2.0)", "twisted (>=9.0.0)" ], "requires_python": "", "summary": "Asynchronous Python HTTP for Humans.", "version": "0.9.6" }, "last_serial": 3520589, "releases": { "0.9.0": [ { "comment_text": "", "digests": { "md5": "0b4a394dc02a5eb2585124bbc4bf79a4", "sha256": "349bd8e2ab524cdc9cb80f614d0c994cd163defb38b64997dcfebcf71e0ed5ef" }, "downloads": -1, "filename": "txrequests-0.9.0.tar.gz", "has_sig": false, "md5_digest": "0b4a394dc02a5eb2585124bbc4bf79a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5122, "upload_time": "2013-09-26T18:47:38", "url": "https://files.pythonhosted.org/packages/9b/cd/dbfb25f4dca435b6c01e16e84a6010efceef4af100cd7d016fec63bf8c27/txrequests-0.9.0.tar.gz" } ], "0.9.2": [ { "comment_text": "", "digests": { "md5": "2657bd814099ee4ba160daa5b058f3f3", "sha256": "dc29e7c9305a74be3e88cd0253bde1981855426e39fbf4a7f4af647542eb7d4e" }, "downloads": -1, "filename": "txrequests-0.9.2.tar.gz", "has_sig": false, "md5_digest": "2657bd814099ee4ba160daa5b058f3f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5223, "upload_time": "2014-04-06T20:45:09", "url": "https://files.pythonhosted.org/packages/a3/8a/a765c9e4b20cb6eb4c85e80536cc939cc2cde4f89a69ff971922ab1c7351/txrequests-0.9.2.tar.gz" } ], "0.9.3": [ { "comment_text": "", "digests": { "md5": "f38d59c5e8c90bccb3d540bab47e7e35", "sha256": "c050728f1544db4057d67b9f39bd4c262a9d69c1c7a3c0e9b633621bbe26886a" }, "downloads": -1, "filename": "txrequests-0.9.3-py2-none-any.whl", "has_sig": true, "md5_digest": "f38d59c5e8c90bccb3d540bab47e7e35", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 6907, "upload_time": "2016-10-19T16:04:52", "url": "https://files.pythonhosted.org/packages/de/a6/6c844482428495f874b945cbdf1021ff85f596e3398d837b69fc559edeb8/txrequests-0.9.3-py2-none-any.whl" } ], "0.9.4": [ { "comment_text": "", "digests": { "md5": "4c6a0e1434578eaec98a441e332be238", "sha256": "2ad7b75f75a5056c273d4eaf67c9c945e42538ad7258f69942d4dc298e9c9ba9" }, "downloads": -1, "filename": "txrequests-0.9.4-py2-none-any.whl", "has_sig": true, "md5_digest": "4c6a0e1434578eaec98a441e332be238", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 6907, "upload_time": "2016-10-19T17:22:24", "url": "https://files.pythonhosted.org/packages/98/f5/3ad5948c6fae1603a5245e217173a0403e443b384421fb8337c96f9f2cf9/txrequests-0.9.4-py2-none-any.whl" } ], "0.9.5": [ { "comment_text": "", "digests": { "md5": "f39791b9abb7428ae5b5a2904513d01f", "sha256": "11e4920f0b8b70a94d1c660c4d576ad607f323f93d5453d535f3ae935d77ab13" }, "downloads": -1, "filename": "txrequests-0.9.5-py2-none-any.whl", "has_sig": false, "md5_digest": "f39791b9abb7428ae5b5a2904513d01f", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 6877, "upload_time": "2016-10-19T18:55:10", "url": "https://files.pythonhosted.org/packages/fa/8f/4eabf606a70168dcc3998bf99c2af08f80cc282449d981a47d1e19673037/txrequests-0.9.5-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b1c7e3006aa2fed4307a3aca303ed40b", "sha256": "43a23d8ba1da713899b6bd766218683535c2c81b9b50d256b073fe18662cf0ab" }, "downloads": -1, "filename": "txrequests-0.9.5.tar.gz", "has_sig": false, "md5_digest": "b1c7e3006aa2fed4307a3aca303ed40b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5265, "upload_time": "2016-10-27T10:01:44", "url": "https://files.pythonhosted.org/packages/8c/bc/408af7381f134c7d7bb8497d4c1bc88448205e1da9be0775fb4741ed484e/txrequests-0.9.5.tar.gz" } ], "0.9.6": [ { "comment_text": "", "digests": { "md5": "7e803056d6c3c592ad54d208ec8daaad", "sha256": "a8e50c5420f23957f12824c37e5858fa359e6108b36d41929a3caf41d6a137fd" }, "downloads": -1, "filename": "txrequests-0.9.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7e803056d6c3c592ad54d208ec8daaad", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6887, "upload_time": "2018-01-25T14:00:58", "url": "https://files.pythonhosted.org/packages/1d/2d/9db3ec81e56323d71422583da04d19c544681b26b64ad4375b1c3fb68271/txrequests-0.9.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b8646167152935d2ad6d40328ee1882a", "sha256": "b452a1cafa4d005678f6fa47922a330feb4907d5b4732d1841ca98e89f1362e1" }, "downloads": -1, "filename": "txrequests-0.9.6.tar.gz", "has_sig": false, "md5_digest": "b8646167152935d2ad6d40328ee1882a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5306, "upload_time": "2018-01-25T14:01:00", "url": "https://files.pythonhosted.org/packages/ed/97/1524061c7fe257092c25c1cf2cd9a8f19662a05ccf31a3d825476eda75ac/txrequests-0.9.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7e803056d6c3c592ad54d208ec8daaad", "sha256": "a8e50c5420f23957f12824c37e5858fa359e6108b36d41929a3caf41d6a137fd" }, "downloads": -1, "filename": "txrequests-0.9.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7e803056d6c3c592ad54d208ec8daaad", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6887, "upload_time": "2018-01-25T14:00:58", "url": "https://files.pythonhosted.org/packages/1d/2d/9db3ec81e56323d71422583da04d19c544681b26b64ad4375b1c3fb68271/txrequests-0.9.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b8646167152935d2ad6d40328ee1882a", "sha256": "b452a1cafa4d005678f6fa47922a330feb4907d5b4732d1841ca98e89f1362e1" }, "downloads": -1, "filename": "txrequests-0.9.6.tar.gz", "has_sig": false, "md5_digest": "b8646167152935d2ad6d40328ee1882a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5306, "upload_time": "2018-01-25T14:01:00", "url": "https://files.pythonhosted.org/packages/ed/97/1524061c7fe257092c25c1cf2cd9a8f19662a05ccf31a3d825476eda75ac/txrequests-0.9.6.tar.gz" } ] }