{ "info": { "author": "Fl\u00e1vio Juvenal", "author_email": "flaviojuvenal@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Topic :: Utilities" ], "description": "# retry\\_on\\_exceptions decorator\nDecorator for retrying a function N times by catching one of the specified exceptions and then retrying.\nSpecially useful for functions that throws errors sporadically, like ones that depends on external resources as web APIs, databases, etc.\n\nUsage:\n\n from retry import retry_on_exceptions\n\n current_try = 0\n @retry_on_exceptions(types=[ZeroDivisionError, KeyError], tries=3)\n def test():\n global current_try\n current_try += 1\n if current_try == 1:\n return 1 / 0\n elif current_try == 2:\n return dict()['key']\n else:\n return \"Got it on last try!\" \n\n if __name__ == \"__main__\":\n print test()\n\nThe code above prints (if root logger is active and on debug level):\n\n- Retrying function test\n- Retrying function test\n- Last try... and I will raise up whatever exception is raised\n- Got it on last try!\n\nOptionally, you can also specify a delay (a float in seconds), making the current thread sleep between tries:\n \n @retry_on_exceptions(types=[urllib2.URLError], tries=3, delay=3.5)", "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/fjsj/retry_on_exceptions", "keywords": "decorator decorators retry exception", "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "retry_on_exceptions", "package_url": "https://pypi.org/project/retry_on_exceptions/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/retry_on_exceptions/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/fjsj/retry_on_exceptions" }, "release_url": "https://pypi.org/project/retry_on_exceptions/0.1/", "requires_dist": null, "requires_python": null, "summary": "Decorator for retrying a function N times in case some specified exception occurs.", "version": "0.1" }, "last_serial": 798927, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "64e32715bbe43b4fe4179d64f594c69c", "sha256": "55dbb360d91917b7845ef144130585c4a62f39657908c4d76d6ea4149f5b192f" }, "downloads": -1, "filename": "retry_on_exceptions-0.1.tar.gz", "has_sig": false, "md5_digest": "64e32715bbe43b4fe4179d64f594c69c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3281, "upload_time": "2012-09-28T20:25:41", "url": "https://files.pythonhosted.org/packages/8c/ba/bbffc287baadfb3238085881b9cbdeb4b9b07135a13b2cb9757ec87c3316/retry_on_exceptions-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "64e32715bbe43b4fe4179d64f594c69c", "sha256": "55dbb360d91917b7845ef144130585c4a62f39657908c4d76d6ea4149f5b192f" }, "downloads": -1, "filename": "retry_on_exceptions-0.1.tar.gz", "has_sig": false, "md5_digest": "64e32715bbe43b4fe4179d64f594c69c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3281, "upload_time": "2012-09-28T20:25:41", "url": "https://files.pythonhosted.org/packages/8c/ba/bbffc287baadfb3238085881b9cbdeb4b9b07135a13b2cb9757ec87c3316/retry_on_exceptions-0.1.tar.gz" } ] }