{ "info": { "author": "Edgeware", "author_email": "info@edgeware.tv", "bugtrack_url": null, "classifiers": [], "description": "[![Build Status](https://travis-ci.org/edgeware/python-circuit.svg?branch=master)](https://travis-ci.org/edgeware/python-circuit)\n\nA circuit breaker according to the logic outline in Michael T. Nygard's\ngreat book [Release It!](http://www.amazon.com/Release-It-Production-Ready-Pragmatic-Programmers/dp/0978739213).\n\nRead: http://en.wikipedia.org/wiki/Circuit_breaker_design_pattern\n\nThe circuit breaker monitors communication with a remote peer and in\nthe case of a high error rate may break the circuit and not allow\nfurther communication for a short period. After a while the breaker\nwill let through a single request to probe to see if the peer feels\nbetter. If it does, it will close the circuit and allow requests once\nagain. If not, it will open the circuit again.\n\nA `CircuitBreakerSet` can handle the state for multiple peers at the\nsame time. Use the `context` method to pick which peer to track. The\nfirst argument is used to identify the peer. Make it a string of some\nkind, since it will be used to identify the peer in logs.\n\nBelow is a small example of how the circuit breaker can be used:\n\n```python\nimport logging\nimport time\n\nfrom circuit import CircuitBreakerSet\n\ncircuit_breaker = CircuitBreakerSet(time.time, logging.getLogger(\n 'circuit-breaker'))\ncircuit_breaker.handle_error(ValueError)\n\ndef fn(circuit_breaker):\n try:\n with circuit_breaker.context('my-remote-peer'):\n raise ValueError('oh no')\n except CircuitOpenError:\n # the circuit was open so we did not even try to communicate\n # with the remote service.\n raise\n```\n\nIf you call `fn` often enough the circuit breaker will open and\n`CircuitOpenError` will be raised.\n\nThe `CircuitBreakerSet` class takes a few keyword arguments:\n\n* `time_unit` (default 60) -- Number of seconds to sample seconds over.\n* `maxfail` (default 3) -- Number of seconds that is allowed over a time unit.\n* `reset_timeout` (default 10) -- Seconds that the circuit is open before\n going into half-open mode.\n\nIt is also possible to create a single instance of a circuit breaker. The\n`circuit.CircuitBreaker` class takes the following arguments:\n\n* `clock` -- A callable that returns the time in seconds.\n* `log` -- a `logging.Logger` object used for logging.\n* `error_types` -- A list of error types that are treated as errors.\n* `maxfail` -- Number of seconds that is allowed over a time unit.\n* `reset_timeout` -- Seconds that the circuit is open before\n going into half-open mode.\n* `time_unit` -- Number of seconds to sample seconds over.\n\n\n# Twisted Support #\n\nThere's also support for using the circuit breaker with Twisted. Note that\nthe circuit breaker still use pythons standard logging framework. Example:\n\n```python\nimport logger\n\nfrom circuit import TwistedCircuitBreakerSet\n\ncircuit_breaker = TwistedCircuitBreakerSet(reactor, logging.getLogger(\n 'circuit-breaker'))\n```\n\n(The `TwistedCircuitBreakerSet` adds support for `defer.returnValue`\nwhich uses exceptions internally.)\n\n# License #\n\nCopyright 2012 Edgeware AB.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n\n# Thanks #\n\n* Michael Nygard, http://www.michaelnygard.com/, for writing the Release It!\n book that outlines the circuit breaker pattern\n\n* Edgeware, http://www.edgeware.tv/, for sponsoring the development of\n python-circuit.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/edgeware/python-circuit", "keywords": "", "license": "Apache v2.0 License", "maintainer": "", "maintainer_email": "", "name": "python-circuit", "package_url": "https://pypi.org/project/python-circuit/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/python-circuit/", "project_urls": { "Homepage": "https://github.com/edgeware/python-circuit" }, "release_url": "https://pypi.org/project/python-circuit/0.1.9/", "requires_dist": null, "requires_python": "", "summary": "Simple implementation of the Circuit Breaker pattern", "version": "0.1.9" }, "last_serial": 3780383, "releases": { "0.0": [ { "comment_text": "", "digests": { "md5": "cdaa4f3ea5b5c3c0741ee9a9830ffc52", "sha256": "7993011ee20a0eea60a6037124ef2b27173ec003f4617d4ac39de114c1a9cb9e" }, "downloads": -1, "filename": "python-circuit-0.0.tar.gz", "has_sig": false, "md5_digest": "cdaa4f3ea5b5c3c0741ee9a9830ffc52", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4399, "upload_time": "2012-06-25T14:34:17", "url": "https://files.pythonhosted.org/packages/cc/38/d96231c616c3081da4364a173bc06bbab275061cfcc5a288f381980566bb/python-circuit-0.0.tar.gz" } ], "0.0.0-dirty": [], "0.1-dirty": [ { "comment_text": "", "digests": { "md5": "58471cd15115cfdb0cdf82bdffc3cfc7", "sha256": "595610464086415b5e557ebb251565876cc87f2f91dcaffb44ea8f15995d7b39" }, "downloads": -1, "filename": "python-circuit-0.1-dirty.tar.gz", "has_sig": false, "md5_digest": "58471cd15115cfdb0cdf82bdffc3cfc7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4422, "upload_time": "2012-06-27T14:23:14", "url": "https://files.pythonhosted.org/packages/4a/39/dd33eb49264dc1ae87ac8f092e389387574fc207dc17d80dc2b20a08669e/python-circuit-0.1-dirty.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "52f80cc4aafcb6ac0dd30bf40d04158f", "sha256": "70368048cae113ad51d57a3f9e8b274fdfb77292f585cf0b53d28598d8bdef74" }, "downloads": -1, "filename": "python-circuit-0.1.3.tar.gz", "has_sig": false, "md5_digest": "52f80cc4aafcb6ac0dd30bf40d04158f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4413, "upload_time": "2012-06-27T15:09:39", "url": "https://files.pythonhosted.org/packages/ee/89/ceae5adf765c3bb1b61b3cde59dce9412eca78e7e4b20eb8252bb9a8d92c/python-circuit-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "4d4abb0e4450e03d31dbec400beb104c", "sha256": "445ac97825620a3492d3a0f95e96ee7e9f84934f84664863d4eae189a414abb6" }, "downloads": -1, "filename": "python-circuit-0.1.4.tar.gz", "has_sig": false, "md5_digest": "4d4abb0e4450e03d31dbec400beb104c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9737, "upload_time": "2012-08-16T13:30:20", "url": "https://files.pythonhosted.org/packages/8c/16/537020665ed7932f7801d5c74c3c3c109d3fb2c29399aafb069d691be5fd/python-circuit-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "4ccd9f849a97f3b44e74fe20c9eb9eb0", "sha256": "4b12a62f09c09587800bddc333186bd19a7f7a4ed6b5887f0b6304131e8104c7" }, "downloads": -1, "filename": "python-circuit-0.1.5.tar.gz", "has_sig": false, "md5_digest": "4ccd9f849a97f3b44e74fe20c9eb9eb0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9726, "upload_time": "2012-08-27T13:50:58", "url": "https://files.pythonhosted.org/packages/97/a7/fde78488c181b1ccd635da516d91d7262c31854aaefc98ee8ac7449f6d9f/python-circuit-0.1.5.tar.gz" } ], "0.1.7": [ { "comment_text": "", "digests": { "md5": "da76d37dd2d53c09d704cc6e440dc57f", "sha256": "2d67b9829a5919f28928cdccc286bf875320ceb740973972993b6f1ae150943e" }, "downloads": -1, "filename": "python_circuit-0.1.7-py2-none-any.whl", "has_sig": false, "md5_digest": "da76d37dd2d53c09d704cc6e440dc57f", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 7787, "upload_time": "2016-07-11T08:28:51", "url": "https://files.pythonhosted.org/packages/f6/06/75573abe076a5941e8345811cbb287db269aa95c689d787ffb566aab67ba/python_circuit-0.1.7-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3e3a92b473d65bbf11ab5d52e183d295", "sha256": "5ed783f6160a2204cdeef63fe6ae4bb56d1a0ae771acece44550140e5aacbdac" }, "downloads": -1, "filename": "python-circuit-0.1.7.tar.gz", "has_sig": false, "md5_digest": "3e3a92b473d65bbf11ab5d52e183d295", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5114, "upload_time": "2016-07-11T08:28:55", "url": "https://files.pythonhosted.org/packages/57/21/b4001119ddd24b7cd77e8013152fc3d374a983a65c0983f98f5da8c204cf/python-circuit-0.1.7.tar.gz" } ], "0.1.8": [ { "comment_text": "", "digests": { "md5": "81433df73b42b3ba8966f70ffb7b5ad9", "sha256": "470a890ac3f701946536849888a2935041511d49c236a9e8905a04394a3860aa" }, "downloads": -1, "filename": "python_circuit-0.1.8-py2-none-any.whl", "has_sig": false, "md5_digest": "81433df73b42b3ba8966f70ffb7b5ad9", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 8431, "upload_time": "2016-07-11T08:29:28", "url": "https://files.pythonhosted.org/packages/07/12/f5b980f583e1bef65f031245efea5d96fcbc1ce07dd6bdc49233e3db53c2/python_circuit-0.1.8-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e14e09f66e1d1d124354c7fc21c1596f", "sha256": "3db55f74c088e4e1feff4ff461e244ccc6615ac2614d8044ce18e69aa0a3e5f6" }, "downloads": -1, "filename": "python-circuit-0.1.8.tar.gz", "has_sig": false, "md5_digest": "e14e09f66e1d1d124354c7fc21c1596f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5224, "upload_time": "2016-07-11T08:29:32", "url": "https://files.pythonhosted.org/packages/89/43/991504f5613da87ca24f06676e1ebdaad74f16db4fd39d05e64dcbdf20ea/python-circuit-0.1.8.tar.gz" } ], "0.1.9": [ { "comment_text": "", "digests": { "md5": "3ad40593349b5289cc41a6526843e0a3", "sha256": "166724c36c4801c3bda372c1ee49de60f074ca3686bb553efac76271f2d59807" }, "downloads": -1, "filename": "python_circuit-0.1.9-py2-none-any.whl", "has_sig": false, "md5_digest": "3ad40593349b5289cc41a6526843e0a3", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 8971, "upload_time": "2016-07-11T08:31:38", "url": "https://files.pythonhosted.org/packages/4b/6a/cc8c9aebfa077bedfc4a76797823223f39d3a162d943098b8810bb7fc056/python_circuit-0.1.9-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5ec43e27e05a45989a0328474cd963ea", "sha256": "c025a4ef15dde2498f1f7e86fa9f1186c77d76230426a083e83b9a16a8df30d4" }, "downloads": -1, "filename": "python-circuit-0.1.9.tar.gz", "has_sig": false, "md5_digest": "5ec43e27e05a45989a0328474cd963ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6209, "upload_time": "2016-07-11T08:31:42", "url": "https://files.pythonhosted.org/packages/c4/68/863099f469432374b3f4bf78e7ce20cf768df3ef20b893431d8ee11be0c6/python-circuit-0.1.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3ad40593349b5289cc41a6526843e0a3", "sha256": "166724c36c4801c3bda372c1ee49de60f074ca3686bb553efac76271f2d59807" }, "downloads": -1, "filename": "python_circuit-0.1.9-py2-none-any.whl", "has_sig": false, "md5_digest": "3ad40593349b5289cc41a6526843e0a3", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 8971, "upload_time": "2016-07-11T08:31:38", "url": "https://files.pythonhosted.org/packages/4b/6a/cc8c9aebfa077bedfc4a76797823223f39d3a162d943098b8810bb7fc056/python_circuit-0.1.9-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5ec43e27e05a45989a0328474cd963ea", "sha256": "c025a4ef15dde2498f1f7e86fa9f1186c77d76230426a083e83b9a16a8df30d4" }, "downloads": -1, "filename": "python-circuit-0.1.9.tar.gz", "has_sig": false, "md5_digest": "5ec43e27e05a45989a0328474cd963ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6209, "upload_time": "2016-07-11T08:31:42", "url": "https://files.pythonhosted.org/packages/c4/68/863099f469432374b3f4bf78e7ce20cf768df3ef20b893431d8ee11be0c6/python-circuit-0.1.9.tar.gz" } ] }