{ "info": { "author": "Young King", "author_email": "y@zhihu.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3" ], "description": "==================================\nA lazy connection context manager\n==================================\nA lazy connection context manager\n\n\n\u4f7f\u7528\u8bf4\u660e\n=======================\n`LazyConnection` \u662f\u4e00\u4e2a\u7ebf\u7a0b\u5b89\u5168\u7684\u8fde\u63a5\u7ba1\u7406\u5668\uff0c\u5b83\u5c06\u4f1a\u521b\u5efa\u4e00\u4e2a\u8fde\u63a5\u4e0a\u4e0b\u6587(context)\uff0c\u8fd9\u4e2a\u4e0a\u4e0b\u6587\u7ba1\u7406\u4e00\u5806\u5728\u5b83\u4e0a\u9762\u6ce8\u518c\u7684\u5de5\u573a\u51fd\u6570(factory)\u3002\n\n- \u5728context \u7684\u751f\u547d\u5468\u671f\u8303\u56f4\u5185\uff0cfactory \u5c06\u4f1a\u6839\u636e\u4f7f\u7528\u5230\u7684\u60c5\u51b5\u6309\u9700\u521b\u5efa(\u6700\u591a\u53ea\u4f1a\u88ab\u521b\u5efa\u4e00\u6b21), \u901a\u8fc7\u4ee5 context \u4e0a\u6ce8\u518c\u7684\u540d\u5b57\u4f5c\u4e3a\u5c5e\u6027\u6765\u8bbf\u95ee,\n \u53ef\u5f97\u5230\u8be5 factory \u7684\u4e00\u4e2a\u5b9e\u4f8b\u3002\n\n- \u5728context \u7684\u751f\u547d\u5468\u671f\u7ed3\u675f\u65f6\uff0c\u5c06\u4f1a\u81ea\u52a8\u6267\u884c\u6e05\u7406\u5de5\u4f5c\uff0cfactory \u7684\u5b9e\u4f8b\u4f1a\u88ab\u9500\u6bc1\uff0c\u5982\u679c\u6709 close \u65b9\u6cd5\u4e5f\u5c06\u88ab\u8c03\u7528\u3002\n\n\u4f7f\u7528\u8303\u4f8b::\n\n from lazyconn import LazyConnection\n\n def create_test1_client():\n return snow(host='127.0.0.1', port=1234)\n\n def create_test2_client1():\n return wish(host='127.0.0.1', port=1235)\n\n # register\n LazyConnection.register_factory('test', create_test1_client)\n LazyConnection.register_factory('test2', create_test2_client)\n\n # context life\n with LazyConnection() as conn:\n conn.test1.hello('wayhome')\n\n`lg` \u662f\u4e00\u4e2a\u7ebf\u7a0b\u5b89\u5168\u7684\u5168\u5c40\u5bf9\u8c61\uff0c\u5b83\u53ea\u5728\u8fde\u63a5\u4e0a\u4e0b\u6587\u4e2d\u6709\u6548\uff0c\u5b83\u7684 **conn** \u5c5e\u6027\u5bf9\u5e94\u4e00\u4e2a\u8fde\u63a5\u4e0a\u4e0b\u6587\u3002\n\n.. note:: \u5728 context \u751f\u547d\u5468\u671f\u5916\uff0c\u4e0d\u80fd\u4f7f\u7528\u6b64\u5bf9\u8c61\u3002\n\n\u4f7f\u7528\u8303\u4f8b::\n\n from lazyconn.globals import lg\n\n with LazyConnection() as conn:\n conn.test1.hello('wayhome')\n lg.conn.test1.hello('wayhome2')\n\n\n`thread_safe` \u662f\u4e00\u4e2a\u88c5\u9970\u5668, \u88ab\u88c5\u9970\u7684\u51fd\u6570\u5c06\u4f1a\u5728\u4e00\u4e2a\u8fde\u63a5\u4e0a\u4e0b\u6587\u4e2d\u6267\u884c\u3002`lg` \u5bf9\u8c61\u53ef\u4ee5\u5728\u88ab\u88c5\u9970\u7684\u51fd\u6570\u5185\u90e8\u4f7f\u7528\u3002\n\n\u4f7f\u7528\u8303\u4f8b::\n\n from lazyconn import thread_safe\n\n @thread_safe\n def test():\n lg.conn.test1.hello('wayhome3')\n\n\n\n\nHistory\n-------\n\n0.1.0 (2013-08-11)\n++++++++++++++++++\n\n* First release on PyPI.", "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/youngking/lazyconn", "keywords": "lazyconn", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "lazyconn", "package_url": "https://pypi.org/project/lazyconn/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/lazyconn/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/youngking/lazyconn" }, "release_url": "https://pypi.org/project/lazyconn/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "A lazy connection context manager", "version": "0.1.0" }, "last_serial": 970627, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "00dd333ce745586e5b52b9f7c048ee5e", "sha256": "8d1665f98ec0e9d6132655ea576707c4afbc3d11caa6e67ec6b56be55f96b190" }, "downloads": -1, "filename": "lazyconn-0.1.0.tar.gz", "has_sig": false, "md5_digest": "00dd333ce745586e5b52b9f7c048ee5e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7848, "upload_time": "2014-01-16T07:47:34", "url": "https://files.pythonhosted.org/packages/79/a0/88d7bd1c9f6beaa70a52a3752b93f4eb596ef1df0143e11b7f11aa5a299a/lazyconn-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "00dd333ce745586e5b52b9f7c048ee5e", "sha256": "8d1665f98ec0e9d6132655ea576707c4afbc3d11caa6e67ec6b56be55f96b190" }, "downloads": -1, "filename": "lazyconn-0.1.0.tar.gz", "has_sig": false, "md5_digest": "00dd333ce745586e5b52b9f7c048ee5e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7848, "upload_time": "2014-01-16T07:47:34", "url": "https://files.pythonhosted.org/packages/79/a0/88d7bd1c9f6beaa70a52a3752b93f4eb596ef1df0143e11b7f11aa5a299a/lazyconn-0.1.0.tar.gz" } ] }