{ "info": { "author": "Wes Mason", "author_email": "wes@1stvamp.org", "bugtrack_url": null, "classifiers": [], "description": "trequests\n=========\n\n.. image:: https://travis-ci.org/1stvamp/trequests.png?branch=master\n\nA Tornado async HTTP/HTTPS client adapter for python-requests.\n\nThe problem\n-----------\n\nYou enjoy using `Tornado `_ to build fast non-blocking web applications, and you want to use a library from PyPI that makes a few HTTP requests, but pretty much every dev and their dog uses `Requests `_ to make HTTP requests (rightly so, because it's *awesome*), but requests has no knowledge of the event loop nor can it yield when a socket blocks, which means any time you try to use a library like that it begins to block your request handling and grud-knows what other worlds of pain.\n\nThe solution\n------------\n\nLuckily there are solutions, one such is to use the `greenlet `_ module to wrap blocking operations and swap Tornado coroutines at the right time, there is even the handy `tornalet `_ module which handles this for you.\n\nTo make life even easier, you lucky lucky people, I've created ``trequests``, an async Requests adapter which uses greenlets (via tornalet) and the inbuilt non-blocking HTTP client methos in Tornado, to make any call to a library (utilizing Requests) non-blocking.\n\nInstallation\n------------\n\n.. code-block:: bash\n \n $ pip install trequests\n \nUsage\n-----\n \n.. code-block:: python\n \n # Assume bobs_big_data uses python-requests for HTTP requests\n import bobs_big_data\n \n from tornado.web import RequestHandler\n from trequests import setup_session\n from tornalet import tornalet\n \n # Tell requests to use our AsyncHTTPadapter for the default\n # session instance, you can also pass you own through\n setup_session()\n \n class WebHandler(RequestHandler):\n @tornalet\n def get(self):\n data = {'foo': 'bar'}\n # This will now unblock the current coroutine, like magic\n response = bobs_big_data.BigData(data).post()\n return self.write(response)\n\n\nTests\n-----\n\nTo run the basic testsuite hit up `python setup.py test`.\n\n\nCaveats\n-------\n\n``trequests`` has been used in production in a large scale metrics application, and is a very small and quite simple module.\n\n**However** I've released it as ``0.9.x`` mainly because it's missing 100% compatibility with the Requests adapter API, most noticeably *cookie jar* and *session* support, which I will improve (or please send me a pull request if you fancy adding support), and release as a ``1.x`` branch when I have the time.\n\nAlso at the moment the ``setup_session`` utility actually monkey patches the ``session`` utility functions in Requests, as this was the only way I could see to override the mounts on \"default\" session instances (e.g. those created for every call when a session isn't provided). I'm hoping to change this in the future.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/1stvamp/trequests", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "zymbit-trequests", "package_url": "https://pypi.org/project/zymbit-trequests/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/zymbit-trequests/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/1stvamp/trequests" }, "release_url": "https://pypi.org/project/zymbit-trequests/0.9.5/", "requires_dist": null, "requires_python": null, "summary": "A Tornado async HTTP/HTTPS client adaptor for python-requests", "version": "0.9.5" }, "last_serial": 1894877, "releases": { "0.9.5": [ { "comment_text": "", "digests": { "md5": "870a2fb4fb8be485c09601ddd64937d2", "sha256": "5462c85ba55788f5caf5663b2edd79af1626bb979625dbe12063a75fb28ada07" }, "downloads": -1, "filename": "zymbit-trequests-0.9.5.tar.gz", "has_sig": false, "md5_digest": "870a2fb4fb8be485c09601ddd64937d2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4539, "upload_time": "2016-01-08T13:13:37", "url": "https://files.pythonhosted.org/packages/7a/ae/0ad1ad1bd6a3c5a2b9c84c11cb6fb82085a459e75d3a9f2f94403b7bb965/zymbit-trequests-0.9.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "870a2fb4fb8be485c09601ddd64937d2", "sha256": "5462c85ba55788f5caf5663b2edd79af1626bb979625dbe12063a75fb28ada07" }, "downloads": -1, "filename": "zymbit-trequests-0.9.5.tar.gz", "has_sig": false, "md5_digest": "870a2fb4fb8be485c09601ddd64937d2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4539, "upload_time": "2016-01-08T13:13:37", "url": "https://files.pythonhosted.org/packages/7a/ae/0ad1ad1bd6a3c5a2b9c84c11cb6fb82085a459e75d3a9f2f94403b7bb965/zymbit-trequests-0.9.5.tar.gz" } ] }