{ "info": { "author": "Mohan Dutt", "author_email": "mohan@oogway.in", "bugtrack_url": null, "classifiers": [], "description": "# pyhystrix\n\n### A library to patch requests package in order to add following functionalities by default:\n\n- Connection and Read timeouts\n- Retries on connection failure\n- Circuitbreaking\n- Adding unique `x-request-id` in request header if not provided\n\n**NOTE:**: 0.0.2 supports python2.7 and >= 0.0.3 supports python3 only.\n\nInstallation\n------------\n\n```sh\npip3 install pyhystrix\n```\n\nUsage\n-----\nBefore making any request, just call `Init()`:\n\n```python\nimport requests\nimport pyhystrix\nrequests.get(\"http://abc.xyx\") // No functionalities of pyhystrix\npyhystrix.Init()\nrequests.get(\"http://abc.xyx\") // pyhystrix is attached to all requests\n```\n\nDefault Configurations can be changed in 2 ways:\n\n1. Setting following env variables:\n\t- `PHY_CONNECT_TIMEOUT` : connection timeout in sec\n\t- `PHY_READ_TIMEOUT`: read timeout in seconds\n\t- `PHY_MAX_RETRIES`: max number of retries for connection failure\n\t- `PHY_CIRCUIT_FAIL_THRESHOLD`: Number of failed requests after which circuit will be open and further requests on the same url will not be allowed.\n\t- `PHY_CIRCUIT_ALIVE_THRESHOLD`: Number of failed requests on open circuit to make it half_open (Described below)\n\t- `PHY_CIRCUIT_DELAY`: Number of seconds after which open circuit will be half_open.\n\n2. parameters in request itself:\n\t- `max_tries`(int): overrides `PHY_MAX_RETRIES`, some rules related to it are follows:\n\t\t- `max_tries=0`: will cause no retries, fail on first failure.\n\t\t- If a positive value is passed for non `GET` requests, they will be retried too in case received status is in `status_forcelist`.\n\t- `status_forcelist`: list of http status, retry if the returned status is one of these. default is `[500]` on `GET`.\n\t- `timeout`: same as timeout in [requests](http://docs.python-requests.org/en/master/user/advanced/#timeouts)\n\t- `backoff_factor`: delay in each retry will be affected by this using following formula: ```{backoff factor} * (2 ^ ({number of total retries} - 1))```. Default = `0.5`sec\n\nMore Examples\n-------------\n- `GET` with retry on multiple failure status codes:\n\n```python\nimport requests\nimport pyhystrix\npyhystrix.Init()\nrequest.get(\"http://abc.xyz\", status_forcelist=[501, 502, 403])\n```\n\n- `put` with retry on response status = `500` or `501`\n\n```python\nrequest.put(\"http://abc.xyz\", max_tries=3, status_forcelist=[500, 502])\n```\n\n**NOTE:** All type of requests will be retried in case of `ConnectionError`\n\nCircuit Breaker States\n---------------\n1. **OPEN** : No requests will be allowed\n2. **HALF_OPEN** : Only one request will be allowed\n3. **CLOSE** : All requests will be allowed.\n\n**NOTE** : State transitions:\n\n`CLOSE --> OPEN --> HALF_OPEN --> CLOSE/OPEN`\n\n### To know more about circuit breaker pattern, click [here](https://martinfowler.com/bliki/CircuitBreaker.html)\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/oogway/pyhystrix", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pyhystrix", "package_url": "https://pypi.org/project/pyhystrix/", "platform": "", "project_url": "https://pypi.org/project/pyhystrix/", "project_urls": { "Homepage": "https://github.com/oogway/pyhystrix" }, "release_url": "https://pypi.org/project/pyhystrix/1.0.0/", "requires_dist": [ "certifi (==2017.4.17)", "chardet (==3.0.4)", "httmock (==1.2.6)", "idna (==2.5)", "requests (==2.22.0)", "urllib3 (==1.25.6)" ], "requires_python": "", "summary": "", "version": "1.0.0" }, "last_serial": 5948033, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "d023ee4422f16185f22aa8c7ad05ff08", "sha256": "9f7b1cdf1e8b793e9288aaba184d651388f77623ce66876c10f94936f9e2476b" }, "downloads": -1, "filename": "pyhystrix-0.0.1-py2-none-any.whl", "has_sig": false, "md5_digest": "d023ee4422f16185f22aa8c7ad05ff08", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 9803, "upload_time": "2018-01-15T06:03:53", "url": "https://files.pythonhosted.org/packages/ae/4f/c25f9c85c92c51b2e118edf731a0f801e92fd3fc6c90253161afa4de1552/pyhystrix-0.0.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a5e92f1c4a8d484525fd422ba961d9a2", "sha256": "e2aebc27c9b7c877b1bf6e3297f64329779c816960572a83f6c76bca0614e546" }, "downloads": -1, "filename": "pyhystrix-0.0.1.tar.gz", "has_sig": false, "md5_digest": "a5e92f1c4a8d484525fd422ba961d9a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6799, "upload_time": "2018-01-15T06:03:55", "url": "https://files.pythonhosted.org/packages/5d/95/1fe61e27b95fd77e15ca4115638b4f8d83c411e28447a21982f950263077/pyhystrix-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "209ce89735d64e2d3dd32dc93cba0149", "sha256": "8566be15543cc0166324ff1a6f18894d9733836da9cff6736dbba80daa66f119" }, "downloads": -1, "filename": "pyhystrix-0.0.2-py2-none-any.whl", "has_sig": false, "md5_digest": "209ce89735d64e2d3dd32dc93cba0149", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 9848, "upload_time": "2018-01-15T06:27:22", "url": "https://files.pythonhosted.org/packages/10/24/efb468d39a3b8be376ea65a9e8f53340a7678c78779c4d1b4f1730222348/pyhystrix-0.0.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5402d407e24fee56d4ef40f148183631", "sha256": "f097bacff47f79bd84d2680a4cd83d313c661e1d53fdba55c1ed31689a337941" }, "downloads": -1, "filename": "pyhystrix-0.0.2.tar.gz", "has_sig": false, "md5_digest": "5402d407e24fee56d4ef40f148183631", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6819, "upload_time": "2018-01-15T06:27:24", "url": "https://files.pythonhosted.org/packages/aa/ac/d48b15fd70ad37716d756c039d5d46b1d1ad115b4d617aa3b9e57d523003/pyhystrix-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "ccb02d176057a90309b7585eff9ea2fd", "sha256": "d8d3ff7fa8f4121dbdef0cb1500c4d2db8c5d6b8798e94625ed39819dce8349f" }, "downloads": -1, "filename": "pyhystrix-0.0.3.tar.gz", "has_sig": false, "md5_digest": "ccb02d176057a90309b7585eff9ea2fd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7065, "upload_time": "2018-03-27T11:58:33", "url": "https://files.pythonhosted.org/packages/a9/01/b8782c26736d544e2257ff446303330bb5b23896b517d2cadefd1546aa79/pyhystrix-0.0.3.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "403592459db853af6dea23cdcedf874d", "sha256": "5ccf7b7e4f6a7da48c5aef11418c51f7dd1c66d9dd4255321967c29518e112f0" }, "downloads": -1, "filename": "pyhystrix-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "403592459db853af6dea23cdcedf874d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8705, "upload_time": "2019-10-09T06:26:44", "url": "https://files.pythonhosted.org/packages/82/81/47196ebef948d44fa0c4a526c3e1754b5794b75a6c13b70330f72fc067fd/pyhystrix-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a7ddc4c7e5244dde484f82b735289645", "sha256": "5e279136373afbcad9e8a5468f38190a15bcd75212eface80e0cf36d6ca07b8b" }, "downloads": -1, "filename": "pyhystrix-1.0.0.tar.gz", "has_sig": false, "md5_digest": "a7ddc4c7e5244dde484f82b735289645", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7055, "upload_time": "2019-10-09T06:26:46", "url": "https://files.pythonhosted.org/packages/c3/bf/2bc63e0d68a5e6a033932b9d5a723bf71d50d606b6668a4f19012f091124/pyhystrix-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "403592459db853af6dea23cdcedf874d", "sha256": "5ccf7b7e4f6a7da48c5aef11418c51f7dd1c66d9dd4255321967c29518e112f0" }, "downloads": -1, "filename": "pyhystrix-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "403592459db853af6dea23cdcedf874d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8705, "upload_time": "2019-10-09T06:26:44", "url": "https://files.pythonhosted.org/packages/82/81/47196ebef948d44fa0c4a526c3e1754b5794b75a6c13b70330f72fc067fd/pyhystrix-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a7ddc4c7e5244dde484f82b735289645", "sha256": "5e279136373afbcad9e8a5468f38190a15bcd75212eface80e0cf36d6ca07b8b" }, "downloads": -1, "filename": "pyhystrix-1.0.0.tar.gz", "has_sig": false, "md5_digest": "a7ddc4c7e5244dde484f82b735289645", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7055, "upload_time": "2019-10-09T06:26:46", "url": "https://files.pythonhosted.org/packages/c3/bf/2bc63e0d68a5e6a033932b9d5a723bf71d50d606b6668a4f19012f091124/pyhystrix-1.0.0.tar.gz" } ] }