{ "info": { "author": "Cedric Zhuang", "author_email": "jealous@163.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Utilities" ], "description": "Retry Decorator\n===============\n\n.. image:: https://img.shields.io/travis/jealous/retryz.svg\n :target: https://travis-ci.org/jealous/retryz\n.. image:: https://img.shields.io/coveralls/jealous/retryz.svg\n :target: https://coveralls.io/github/jealous/retryz\n.. image:: https://img.shields.io/pypi/v/retryz.svg\n :target: https://pypi.python.org/pypi/retryz\n\nVERSION: 0.1.9\n\nIntroduction\n------------\n\nFunction decorator that helps to retry the function under certain criteria.\n\nThis package contains the ``retry`` decorator and a bunch of configuration \nparameters for this decorator. \n\nTested on python 2.7 and python 3.4.\n\nFor quick start, check the tutorial section of this page.\nCheck [test_retryz.py](test/test_retryz.py) for detail examples.\n\nInstallation\n------------\n\n``pip install retryz``\n\n\nLicense\n-------\n\n`Apache License version 2`_\n\nTutorial\n--------\n\n- Retry if `ValueError` is caught.\n\n.. code-block:: python\n\n @retry(on_error=ValueError)\n def my_func():\n ...\n\n- Retry if `ValueError` or `TypeError` is caught.\n\n.. code-block:: python\n\n @retry(on_error=lambda e: isinstance(e, (ValueError, TypeError)))\n def my_func():\n ...\n\n- Retry until `TypeError` is caught.\n\n.. code-block:: python\n\n @retry(on_error=lambda e: not isinstance(e, TypeError))\n def my_func():\n ...\n\n- Retry until `TypeError` or `AttributeError` is caught.\n\n.. code-block:: python\n\n @retry(on_error=lambda e: not isinstance(e, (TypeError, AttributeError)))\n def my_func():\n ...\n\n- When ``on_error`` is a callback,\n it will retry until ``on_error`` returns ``False``. Note that callback \n takes one parameter which is the error instance raised by the decorated \n function.\n\n.. code-block:: python\n\n def _error_callback(self, ex):\n assert_that(ex, instance_of(TypeError))\n return self.call_count != 4\n \n @retry(on_error=_error_callback)\n def error_call_back(self):\n ...\n\n- Retry if returns certain value.\n\n.. code-block:: python\n\n @retry(on_return=True)\n def my_func(self):\n ...\n\n- Retry if return value in the list.\n\n.. code-block:: python\n\n @retry(on_return=lambda x: x in (1, 2, 3, 4, 5))\n def my_func(self):\n ...\n\n- Retry until certain value is returned.\n\n.. code-block:: python\n\n @retry(on_return=lambda x: x != 4)\n def my_func(self):\n ...\n\n- Retry until any of the value is returned.\n\n.. code-block:: python\n\n @retry(on_return=lambda x: x not in [3, 4])\n def my_func(self):\n ...\n\n\n- When ``on_return`` is a callback, \n it will retry until ``on_return`` returns ``False``. Note that callback \n takes one parameter which is the return value of the decorated function.\n\n.. code-block:: python\n\n def _return_callback(ret):\n return 4 + ret < 7\n \n @retry(on_return=_return_callback)\n def my_func(self):\n ...\n\n- Retry until timeout (in seconds)\n\n.. code-block:: python\n \n @retry(timeout=0.1)\n def my_func():\n ...\n\n- Retry maximum X times.\n\n.. code-block:: python\n\n @retry(limit=3)\n def my_func():\n ...\n\n # or you could specify a callback\n @retry(limit=lambda: 4)\n def my_func_x():\n ...\n\n\n- Wait X seconds between each retry.\n\n.. code-block:: python\n\n @retry(wait=0.1, timeout=0.3)\n def my_func():\n ...\n\n\n- When ``wait`` is a callback, it will wait for the amount of\n seconds returned by the callback.\n The callback takes one parameter which is the current count of retry.\n\n.. code-block:: python\n\n def _wait_callback(self, tried):\n return 2 ** tried\n \n @retry(wait=_wait_callback, timeout=0.1)\n def my_func():\n ...\n\n\n- ``on_retry`` could be used to specify a callback. This callback\n is a function with no parameter. It will be invoked before each\n retry. Here is a typical usage.\n\n.. code-block:: python\n\n def do_login():\n # login if not\n ...\n \n @retry(on_retry=do_login, limit=2)\n def requests(resource_id):\n ...\n\n\n- ``retry`` could also be called in a functional style.\n Note that the return value is a function. If you want to call\n it, you need to add an extra ``()``.\n\n.. code-block:: python\n\n def foo():\n ...\n \n retry(foo, limit=3, timeout=5)()\n\n \n\nTo file issue, please visit:\n\nhttps://github.com/jealous/retryz\n\n\nContact author:\n\n- Cedric Zhuang \n\n.. _Apache License version 2: LICENSE.txt", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/jealous/retryz", "keywords": "retry decorator", "license": "Apache Software License", "maintainer": "", "maintainer_email": "", "name": "retryz", "package_url": "https://pypi.org/project/retryz/", "platform": "any", "project_url": "https://pypi.org/project/retryz/", "project_urls": { "Homepage": "http://github.com/jealous/retryz" }, "release_url": "https://pypi.org/project/retryz/0.1.9/", "requires_dist": null, "requires_python": "", "summary": "Retry decorator with a bunch of configuration parameters.", "version": "0.1.9" }, "last_serial": 2888992, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "5f9585721f5dd331fe51234a4945ba65", "sha256": "11eebe5ac8a90b9a464fb26d1ad96ca028e0eb2f85a9c676483aba3ba0739e82" }, "downloads": -1, "filename": "retryz-0.1.0.zip", "has_sig": false, "md5_digest": "5f9585721f5dd331fe51234a4945ba65", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9633, "upload_time": "2015-12-21T10:21:12", "url": "https://files.pythonhosted.org/packages/67/04/6db9c347e4371e91a15f04a37d774da7f047b688e2bca6002a2ee8f07c69/retryz-0.1.0.zip" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "756915e52c72c291b955cb77213a29f2", "sha256": "daf4b46159968adeaeeb53e7d9641db03d489ea2731e0ec76c90557d5f052541" }, "downloads": -1, "filename": "retryz-0.1.1.zip", "has_sig": false, "md5_digest": "756915e52c72c291b955cb77213a29f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9639, "upload_time": "2016-01-04T13:58:46", "url": "https://files.pythonhosted.org/packages/9c/fe/a53df1565858a1a445439738fa83efee00b4d3f88c9b8686c88d7f7505c1/retryz-0.1.1.zip" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "9ebe1257de24f8ff9d1a32c7ffab0369", "sha256": "0ba7152f28d491a0f7591d7fe8ccad2d08eb13dc7fe6dec62faab3fda67d12ed" }, "downloads": -1, "filename": "retryz-0.1.2.zip", "has_sig": false, "md5_digest": "9ebe1257de24f8ff9d1a32c7ffab0369", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9906, "upload_time": "2016-01-13T06:01:19", "url": "https://files.pythonhosted.org/packages/46/49/e93b65d64df4ba7510023f51131a58953b1faaefcbe4986c997acac873c5/retryz-0.1.2.zip" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "f727d40dd784ff9f16bdf005e334eea1", "sha256": "9764dfc93554d16dcbda1fbc2dacb97cd7449a1b8982e033de192897b63fd550" }, "downloads": -1, "filename": "retryz-0.1.3.zip", "has_sig": false, "md5_digest": "f727d40dd784ff9f16bdf005e334eea1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9951, "upload_time": "2016-01-14T03:33:37", "url": "https://files.pythonhosted.org/packages/b1/61/019311d7093bb2782337abe484ddd4aa2dc1bfe426573b3f756bec79ab19/retryz-0.1.3.zip" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "46777d4e1dec6222b8b478b9ed8bb912", "sha256": "d1870d03fce049b7993ae6a00abe5e66a934e63f01379c7c13d38bd41391f880" }, "downloads": -1, "filename": "retryz-0.1.4.zip", "has_sig": false, "md5_digest": "46777d4e1dec6222b8b478b9ed8bb912", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10375, "upload_time": "2016-01-15T16:25:58", "url": "https://files.pythonhosted.org/packages/29/48/94866179d64a4ab17a6a59a072f8466e841833df0e0a1746ddb158d936ad/retryz-0.1.4.zip" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "364c5d9fc46fe7699ec14a83a4541a78", "sha256": "6175c48f542c930a3730ff291b7206b5c8b765ce23d130fd62351e1b8b613228" }, "downloads": -1, "filename": "retryz-0.1.5.zip", "has_sig": false, "md5_digest": "364c5d9fc46fe7699ec14a83a4541a78", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15313, "upload_time": "2016-03-23T09:22:19", "url": "https://files.pythonhosted.org/packages/ee/00/69fd8ce5a8daca77337590afdd5e65fa21892e3af472e4b199f5f289a7ff/retryz-0.1.5.zip" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "63abde244cd4246a16dd2b6d6e5e1006", "sha256": "1312c6649aea239e5abb97a7161d2ba37d088dea5dc6860b65e2c66f828786f5" }, "downloads": -1, "filename": "retryz-0.1.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "63abde244cd4246a16dd2b6d6e5e1006", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10122, "upload_time": "2016-05-19T04:07:42", "url": "https://files.pythonhosted.org/packages/4b/ef/2d8518f835faaf3e76811150324331e428716e06f3ad4304502fbebbf5fd/retryz-0.1.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "302edae81207e6e709a651fee07ae68f", "sha256": "e7c3157972a5994cf08aad05052b09fa0735677002939034311389dd7b266fca" }, "downloads": -1, "filename": "retryz-0.1.6.zip", "has_sig": false, "md5_digest": "302edae81207e6e709a651fee07ae68f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15439, "upload_time": "2016-06-21T03:45:46", "url": "https://files.pythonhosted.org/packages/1b/f0/b9bb938e311278676d9a517eac0ecce71dcd8aa122c4d143928230cf5fa3/retryz-0.1.6.zip" } ], "0.1.7": [ { "comment_text": "", "digests": { "md5": "1475379d73fe639c78079914f1bcae04", "sha256": "0e251600694e064f8c64d1b081f31ce34a653aba5be3962532c84c5737d862d1" }, "downloads": -1, "filename": "retryz-0.1.7-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1475379d73fe639c78079914f1bcae04", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10088, "upload_time": "2016-06-21T04:29:13", "url": "https://files.pythonhosted.org/packages/6f/c2/771bec91b0e8041e223b4a187b7f81ec99f039878f7e89c963de341ea21e/retryz-0.1.7-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7a4e385e67124349eef1eb0b2f6cd9f8", "sha256": "1728397c0cb1b647ea4152c6fa196a61072eda6da5a9edb45628fc56ace526d8" }, "downloads": -1, "filename": "retryz-0.1.7.zip", "has_sig": false, "md5_digest": "7a4e385e67124349eef1eb0b2f6cd9f8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15554, "upload_time": "2016-06-21T04:29:19", "url": "https://files.pythonhosted.org/packages/95/48/ff04b2d0336df1a9c0e620b50f109db6acf847426b5039f9517c84e558cb/retryz-0.1.7.zip" } ], "0.1.8": [ { "comment_text": "", "digests": { "md5": "f0cf692c6b21caa46b25713614e34300", "sha256": "d5d2017a8d334a53f6a8b03d83a32c30d9aa6875b2f3497431290ffeeaaf8b83" }, "downloads": -1, "filename": "retryz-0.1.8.zip", "has_sig": false, "md5_digest": "f0cf692c6b21caa46b25713614e34300", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15638, "upload_time": "2016-08-02T09:06:08", "url": "https://files.pythonhosted.org/packages/a8/5b/35f5e9c23b533a676b831c695671b54d2d0781d121989ee07bf80c290f78/retryz-0.1.8.zip" } ], "0.1.9": [ { "comment_text": "", "digests": { "md5": "57e5ffe484c24d9ee9794b2e21a12914", "sha256": "8f4598c7fe02492789b05ecf59074908775bb0e3ce6486c17edc6b5710e1f19c" }, "downloads": -1, "filename": "retryz-0.1.9-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "57e5ffe484c24d9ee9794b2e21a12914", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 10131, "upload_time": "2017-05-21T15:19:55", "url": "https://files.pythonhosted.org/packages/cf/eb/f52955956596f857ff64cc4c689b5d4c77bc2aaec7f86f5ff5d87d013826/retryz-0.1.9-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "31b3dcbf34bd5ad6a6709044242c0e3e", "sha256": "d8a138009ca66032e6bd39e1bc0a5d8f3bc0f272763c8646ad73d1b6faf37915" }, "downloads": -1, "filename": "retryz-0.1.9.tar.gz", "has_sig": false, "md5_digest": "31b3dcbf34bd5ad6a6709044242c0e3e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10319, "upload_time": "2017-05-21T15:19:52", "url": "https://files.pythonhosted.org/packages/39/2b/9acb4ee95954db400cfa056d2d7f06860f12902c33db9f3bc149f1d657b1/retryz-0.1.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "57e5ffe484c24d9ee9794b2e21a12914", "sha256": "8f4598c7fe02492789b05ecf59074908775bb0e3ce6486c17edc6b5710e1f19c" }, "downloads": -1, "filename": "retryz-0.1.9-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "57e5ffe484c24d9ee9794b2e21a12914", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 10131, "upload_time": "2017-05-21T15:19:55", "url": "https://files.pythonhosted.org/packages/cf/eb/f52955956596f857ff64cc4c689b5d4c77bc2aaec7f86f5ff5d87d013826/retryz-0.1.9-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "31b3dcbf34bd5ad6a6709044242c0e3e", "sha256": "d8a138009ca66032e6bd39e1bc0a5d8f3bc0f272763c8646ad73d1b6faf37915" }, "downloads": -1, "filename": "retryz-0.1.9.tar.gz", "has_sig": false, "md5_digest": "31b3dcbf34bd5ad6a6709044242c0e3e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10319, "upload_time": "2017-05-21T15:19:52", "url": "https://files.pythonhosted.org/packages/39/2b/9acb4ee95954db400cfa056d2d7f06860f12902c33db9f3bc149f1d657b1/retryz-0.1.9.tar.gz" } ] }