{ "info": { "author": "Tom Tang", "author_email": "tly1980@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "=============================\n Async Keep-Alive Http Client\n=============================\n:Info: See for introductory docs.\n:Author: Tom Tang \n:Date: .. |date|\n:Description: Async Keep-Alive Http Client\n\nKeep-alive_ is a well-known and popular technique to reduce the latencies and speed up the resource retrival.\n(See )\n\nIt allows one connection to request multiple resources, which can avoid\nthe penalties of establishing and closing a HTTP connection, and quite significantly for HTTPS connection.\n\nTornado_ is highly efficient Python asynchronous web framework & network libary. \nand I am quite enjoying using to build high performance web application.\nHowever, Tornado_ does not ship with a httpclient that support Keep-alive out of box up to now (v3.1.1 October, 2013.)\n\nAnd that is exactly why I created this libaray, which comes with a HTTP client that supports Keep-Alive feature.\nThis client is basically a hack of tornado Httpclient and HttpConnection, so the API is very much the same, \nwhich means it can use Tornado HTTPRequest and most feature of the original client \n(like gzip, proxies, .etc - Warrning: further tests needed to be conducted for this features.).\n\nA Proxy_ feature is included since version 0.13. The proxy implementation is using pycurl, so the the Keep-Alive feature would be disabled. \n\nBesides that, the libaray also provide a Queue Function limited support to some of the AWS services: SQS and DyanmoDB.\nAnd, last but not least, a simple resource pool.\n\n.. _Tornado: http://www.tornadoweb.org/en/stable\n\n.. _Keep-alive: http://en.wikipedia.org/wiki/HTTP_persistent_connection\n\n.. technique_: http://chimera.labs.oreilly.com/books/1230000000545/ch11.html#BENEFITS_OF_KEEPALIVE\n\n.. _Proxy: http://en.wikipedia.org/wiki/Proxy_server\n\n\nExample\n=======\n.. code-block:: python\n \n from async_keepalive_httpc.keepalive_client import SimpleKeepAliveHTTPClient\n \n \n ska_client = SimpleKeepAliveHTTPClient(self.io_loop)\n \n # just assume that you have a http server that supports connection keep-alive and\n # it has a.txt which just has a simple text 'aaa'. Accordingly, b.txt has a simple text\n # 'bbb', so is 'ccc' in c.txt\n \n a, b, c = yield [\n ska_client.fetch('http://localhost/a.txt'),\n ska_client.fetch('http://localhost/b.txt'),\n ska_client.fetch('http://localhost/c.txt'),\n ]\n \n assert 'aaa' in a.body\n assert 'bbb' in b.body\n assert 'ccc' in c.body\n \n # The client should fetch them using just one connection, \n # rather than disconnect and connect reapeatly.\n assert ska_client.connection.connect_times == 1\n \n \n===========\nAWS Support\n===========\n\nSQS\n===\n\n.. code-block:: python\n\n from async_keepalive_httpc.aws.sqs import SQSQueue\n\n q = SQSQueue(\n io_loop,\n 'AWS_ACCESS_KEY',\n 'AWS_SECRET_KEY',\n 'https://ap-southeast-2.queue.amazonaws.com/YOUR_ACCOUNT_NUMBER/YOUR_QUEUE_NAME',\n endpoints='ap-southeast-2')\n\n r1 = yield q.send('abc')\n r2 = yield q.send('cde')\n r3 = yield q.send('fgh')\n\n assert r1.code == 200\n assert r2.code == 200\n assert r3.code == 200\n\n # make sure it is 'keep-alive'\n assert q.client.connection.connect_times == 1\n \n\nDynamoDB\n========\n\n.. code-block:: python\n \n from async_keepalive_httpc.aws.dynamodb import DynamoDB\n \n db = DynamoDB(\n self.io_loop,\n 'AWS_ACCESS_KEY',\n 'AWS_SECRET_KEY',\n endpoints='ap-southeast-2')\n \n resp = yield db.get_item('TEST_USER_DATA', \n {\n 'USER_ID': {'S':'EEB750F4-C589-4C0A-95C3-C1B572A0CC3E'}, \n }, \n attributes_to_get = ['Name']\n )\n\n print resp.aws_result\n\n\nOutput would be something like:\n\n.. code-block:: python\n\n {\n 'Item': { \n 'DATA': { \n 'S': 'Tom Cruse'\n }\n }\n }\n\n\nResource Pool\n=============\n\n.. code-block:: python\n\n from tornado.testing import AsyncTestCase, gen_test\n from async_keepalive_httpc.keepalive_client import SimpleKeepAliveHTTPClient\n from async_keepalive_httpc.pool import ResourcePool\n \n \n class ResourcePoolTestCase(AsyncTestCase):\n \n @gen_test\n def test_basic(self):\n create_func = lambda: SimpleKeepAliveHTTPClient(self.io_loop)\n pool = ResourcePool(create_func, init_count=2, max_count=3)\n \n self.assertEqual(len(pool._pool), 2)\n ska_client1 = pool.get()\n ska_client1.fetch('http://www.google.com')\n ska_client2 = pool.get()\n \n self.assertNotEqual(ska_client1, ska_client2)\n \n ska_client2.fetch('http://www.google.com')\n \n ska_client3 = pool.get()\n \n ska_client3.fetch('http://www.google.com')\n \n self.assertNotEqual(ska_client1, ska_client3)\n self.assertNotEqual(ska_client2, ska_client3)\n \n ska_client2.fetch('http://www.google.com')\n ska_client3.fetch('http://www.google.com')\n \n ska_client4 = pool.get()\n self.assertEqual(ska_client1, ska_client4)\n\nUsing Proxy\n===========\n\n.. code-block:: python\n\n from async_keepalive_httpc.aws.sqs import SQSQueue\n\n PROXY_CONFIG = {\n 'proxy_host': 'localhost',\n 'proxy_port': 3128,\n }\n\n sqs = SQSQueue(io_loop,\n Q_URL,\n access_key = self.ACCESS_KEY,\n secret_key= self.SECRET_KEY,\n proxy_config=PROXY_CONFIG)\n \n yield sqs.send('my msg via proxy')", "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/tly1980/async_keepalive_httpc", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "async_keepalive_httpc", "package_url": "https://pypi.org/project/async_keepalive_httpc/", "platform": "any", "project_url": "https://pypi.org/project/async_keepalive_httpc/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/tly1980/async_keepalive_httpc" }, "release_url": "https://pypi.org/project/async_keepalive_httpc/0.15/", "requires_dist": null, "requires_python": null, "summary": "An async http client with keep-alive capabilities", "version": "0.15" }, "last_serial": 1027851, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "e58e486cbf52d5dc33101797798b6a7d", "sha256": "9337216ec74001f7ad8f661c575f887bcc5de9ab1fa5894d240de820c83490c3" }, "downloads": -1, "filename": "async_keepalive_httpc-0.1.tar.gz", "has_sig": false, "md5_digest": "e58e486cbf52d5dc33101797798b6a7d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17644, "upload_time": "2013-11-18T11:42:47", "url": "https://files.pythonhosted.org/packages/9c/0c/e05e59e2d85f948538d6599bb670f484f2517b4afa395e68fe0388fe84db/async_keepalive_httpc-0.1.tar.gz" } ], "0.11": [ { "comment_text": "", "digests": { "md5": "5f7d438fb5aadfaf1eeb6649564843d5", "sha256": "8f35505c1e01f8a2d18ca39b72f5c3206156c0a26dd88edab838f51088d72514" }, "downloads": -1, "filename": "async_keepalive_httpc-0.11.tar.gz", "has_sig": false, "md5_digest": "5f7d438fb5aadfaf1eeb6649564843d5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17804, "upload_time": "2013-11-18T23:52:48", "url": "https://files.pythonhosted.org/packages/8d/ca/413d9bff2404985740f3389866eff57810b281d794e27cb4708291d6fcd9/async_keepalive_httpc-0.11.tar.gz" } ], "0.12": [ { "comment_text": "", "digests": { "md5": "c172df6d6e5b454c759db456fcf200b1", "sha256": "29b52cbc9db2c400bf5cc5b18abf138ab25513e2823bf9a072043fd44d058f35" }, "downloads": -1, "filename": "async_keepalive_httpc-0.12.tar.gz", "has_sig": false, "md5_digest": "c172df6d6e5b454c759db456fcf200b1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18237, "upload_time": "2013-11-20T21:25:14", "url": "https://files.pythonhosted.org/packages/27/46/b02460450207dee98645be2f0211fae09a0c469ab15a2240fb62b322eb1a/async_keepalive_httpc-0.12.tar.gz" } ], "0.13": [ { "comment_text": "", "digests": { "md5": "e50b811479a8924cd375ebb713a2b67e", "sha256": "57727791780f3b35b4f1820739b60e5e4b12103cbd206922764894bd9e1bc23c" }, "downloads": -1, "filename": "async_keepalive_httpc-0.13.tar.gz", "has_sig": false, "md5_digest": "e50b811479a8924cd375ebb713a2b67e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18899, "upload_time": "2013-11-26T00:24:50", "url": "https://files.pythonhosted.org/packages/da/02/89f608f2a6135a740764ee85780e5e907b25bb3d3b274cee8a6a09023862/async_keepalive_httpc-0.13.tar.gz" } ], "0.13.1": [ { "comment_text": "", "digests": { "md5": "508ac55bc5ea17f00200e4de453e587b", "sha256": "0f903b54c4ceef4652305dd6d4d12d2a817f38748086c65e2e465612566b8119" }, "downloads": -1, "filename": "async_keepalive_httpc-0.13.1.tar.gz", "has_sig": false, "md5_digest": "508ac55bc5ea17f00200e4de453e587b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16755, "upload_time": "2013-12-10T06:25:47", "url": "https://files.pythonhosted.org/packages/d1/57/ae92d12a9ee0f9c4e31f3af6691b3c2b2b0aa069b3e71a7d8f5a5deec7b5/async_keepalive_httpc-0.13.1.tar.gz" } ], "0.13.2": [ { "comment_text": "", "digests": { "md5": "678b8b134a591d4444952fb55557870a", "sha256": "38b49845d065d3db76e7c2a2710d822d195a131f049314b571c7737e7684570d" }, "downloads": -1, "filename": "async_keepalive_httpc-0.13.2.tar.gz", "has_sig": false, "md5_digest": "678b8b134a591d4444952fb55557870a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18926, "upload_time": "2013-12-12T01:27:48", "url": "https://files.pythonhosted.org/packages/48/c0/41672821405ee8ae83825e4aab4b96af5e864c2490f5a36f89408e0fab6b/async_keepalive_httpc-0.13.2.tar.gz" } ], "0.13.3": [ { "comment_text": "", "digests": { "md5": "592950eaf8ca8d5c623c93df73c28e2a", "sha256": "1b7df38da9a70edb35dd8c6e7df5da616b2b31a5cce615da3b023e801b196f14" }, "downloads": -1, "filename": "async_keepalive_httpc-0.13.3.tar.gz", "has_sig": false, "md5_digest": "592950eaf8ca8d5c623c93df73c28e2a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16770, "upload_time": "2014-01-14T00:11:57", "url": "https://files.pythonhosted.org/packages/e9/0b/cd07e34953a3aa191e3fb8a294334329c1482adb4d67e2b99a2e8b06f2cc/async_keepalive_httpc-0.13.3.tar.gz" } ], "0.13.4": [ { "comment_text": "", "digests": { "md5": "c2aea1b17c57f9eafbcf3e0b6819f5d4", "sha256": "f512b599b2303655357618a95d698e274a0536f715c4779e0243b814e09039cf" }, "downloads": -1, "filename": "async_keepalive_httpc-0.13.4.tar.gz", "has_sig": false, "md5_digest": "c2aea1b17c57f9eafbcf3e0b6819f5d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16756, "upload_time": "2014-01-14T02:12:04", "url": "https://files.pythonhosted.org/packages/72/6b/02ac4c646e9bf7c694346aae1084053879308fa96bc480d8e2282ceec54e/async_keepalive_httpc-0.13.4.tar.gz" } ], "0.14": [ { "comment_text": "", "digests": { "md5": "a8f675ba49494b65e289ca194a83ea78", "sha256": "03368527a012472d4adc989d2b5a036263dbb8011694fe631ae711806e683dfd" }, "downloads": -1, "filename": "async_keepalive_httpc-0.14.tar.gz", "has_sig": false, "md5_digest": "a8f675ba49494b65e289ca194a83ea78", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17276, "upload_time": "2014-02-19T04:56:52", "url": "https://files.pythonhosted.org/packages/a0/6b/f4a2b812f7ae0050d634483027989ada411426c53f96d0c3166e58af0668/async_keepalive_httpc-0.14.tar.gz" } ], "0.15": [ { "comment_text": "", "digests": { "md5": "b924b8d89f0a6fbbc5b7e0d54bb7beb9", "sha256": "2bb36e7fe91c12b31c5771db843011bdbedecca4173f5b64dc69c74c9bd59547" }, "downloads": -1, "filename": "async_keepalive_httpc-0.15.tar.gz", "has_sig": false, "md5_digest": "b924b8d89f0a6fbbc5b7e0d54bb7beb9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17259, "upload_time": "2014-03-13T02:54:43", "url": "https://files.pythonhosted.org/packages/a5/82/51d77e7f4ba24d2a565d2673741df8fb218682e27494f6daeba8d4cf10d5/async_keepalive_httpc-0.15.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b924b8d89f0a6fbbc5b7e0d54bb7beb9", "sha256": "2bb36e7fe91c12b31c5771db843011bdbedecca4173f5b64dc69c74c9bd59547" }, "downloads": -1, "filename": "async_keepalive_httpc-0.15.tar.gz", "has_sig": false, "md5_digest": "b924b8d89f0a6fbbc5b7e0d54bb7beb9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17259, "upload_time": "2014-03-13T02:54:43", "url": "https://files.pythonhosted.org/packages/a5/82/51d77e7f4ba24d2a565d2673741df8fb218682e27494f6daeba8d4cf10d5/async_keepalive_httpc-0.15.tar.gz" } ] }