{ "info": { "author": "Erik van Zijst", "author_email": "erik.van.zijst@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Debuggers", "Topic :: System :: Benchmark", "Topic :: System :: Monitoring", "Topic :: Utilities" ], "description": "Interrupting Cow\n================\n\nInterruptingcow is a generic utility that can relatively gracefully interrupt\nyour Python code when it doesn't execute within a specific number of seconds::\n\n from interruptingcow import timeout\n\n try:\n with timeout(5, exception=RuntimeError):\n # perform a potentially very slow operation\n pass\n except RuntimeError:\n print \"didn't finish within 5 seconds\"\n\nTimeouts are specified in seconds (as floats with theoretical microsecond\nprecision).\n\n\nInstallation\n------------\n::\n\n $ pip install interruptingcow\n\n\nReentrant\n---------\n\nInterruptingcow is fully reentrant, which means that you can have nested\ntimeouts::\n\n from interruptingcow import timeout\n\n class Outer(RuntimeError): pass\n\n class Inner(RuntimeError): pass\n\n try:\n with timeout(20.0, Outer):\n try:\n with timeout(1.0, Inner):\n # some expensive operation\n try_the_expensive_thing()\n except Inner:\n do_the_cheap_thing_instead()\n\n except Outer:\n print 'Program as a whole failed to return in 20 secs'\n\nNested timeouts allow a large outer timeout to contain smaller timeouts. If the\ninner timeout is larger than the outer timeout, it is treated as a no-op.\n\n\nFunction Decorators\n-------------------\n\nInterruptingcow can be used both as inline with-statements, as shown in the\nabove examples, as well as function decorator::\n\n from interruptingcow import timeout\n\n @timeout(.5)\n def foo():\n with timeout(.3):\n # some expensive operation\n pass\n\n\nQuotas\n------\n\nYou can allocate a quota of time and then share it across multiple invocations\nto ``timeout()``. This is especially useful if you need to use timeouts inside\na loop::\n\n from interruptingcow import timeout, Quota\n\n quota = Quota(1.0)\n for i in something:\n try:\n with timeout(quota, RuntimeError):\n # perform a slow operation\n pass\n except RuntimeError:\n # do a cheaper thing instead\n\nHere the first iterations of the loop will be able to perform the expensive\noperation, until the shared quota of 1 second runs out and then the remaining\niterations will perform the cheaper alternative.\n\nA single quota instance can also be shared across all calls to ``timeout()``\nyour application makes (including nested calls), to give place an upper bound\non the total runtime, regardless of how many calls to ``timeout()`` you have.\n\nCaveats\n-------\n\nInterruptingcow uses ``signal(SIGALRM)`` to let the operating system interrupt\nprogram execution. This has the following limitations:\n\n1. Python signal handlers only apply to the main thread, so you cannot use this\n from other threads\n2. You must not use this in a program that uses ``SIGALRM`` itself (this\n includes certain profilers)", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/evzijst/interruptingcow", "keywords": "debug watchdog timer interrupt", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "interruptingcow", "package_url": "https://pypi.org/project/interruptingcow/", "platform": "", "project_url": "https://pypi.org/project/interruptingcow/", "project_urls": { "Homepage": "https://bitbucket.org/evzijst/interruptingcow" }, "release_url": "https://pypi.org/project/interruptingcow/0.8/", "requires_dist": null, "requires_python": "", "summary": "A watchdog that interrupts long running code.", "version": "0.8" }, "last_serial": 3622827, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "6a06fb32fec57740424d09fa52ed8f5b", "sha256": "5e635a28b85b772c45fadb55f8b0f098c0d19e693ffde08eb74faf3718cacebc" }, "downloads": -1, "filename": "interruptingcow-0.1.tar.gz", "has_sig": false, "md5_digest": "6a06fb32fec57740424d09fa52ed8f5b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11607, "upload_time": "2012-03-23T21:45:04", "url": "https://files.pythonhosted.org/packages/16/94/4cf02fd46f93b1c96348944dac16c0a19fc8e0a76dc38f01915891562c52/interruptingcow-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "65a46aac2c09bfe3774d804f48443c97", "sha256": "75eeb854ac5871e4115557448417fd734d94e7696348e4be294ed71fa2c94260" }, "downloads": -1, "filename": "interruptingcow-0.2.tar.gz", "has_sig": false, "md5_digest": "65a46aac2c09bfe3774d804f48443c97", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11550, "upload_time": "2012-03-23T21:49:31", "url": "https://files.pythonhosted.org/packages/dc/79/6c6393e58f745f04ac802c4dd5c9f756507ec7f52cdf8b3c8af0282ff9fa/interruptingcow-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "4dfa5d2ab101ec6b00765049af50779b", "sha256": "67257bdd86116cf1eb283bc8692504f4e21376e07ae185630072ad3ee19b24d1" }, "downloads": -1, "filename": "interruptingcow-0.3.tar.gz", "has_sig": false, "md5_digest": "4dfa5d2ab101ec6b00765049af50779b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11478, "upload_time": "2012-06-02T18:02:46", "url": "https://files.pythonhosted.org/packages/df/34/79579d399e8629f14cad80b2ade92c73210e455549bbbe7e8c09d4b51145/interruptingcow-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "3769fbf8938576b5bf9a98267c18981a", "sha256": "376e9327668286429a15e5212f2cce38135f6437f6b7e4c1314226cd7a320a27" }, "downloads": -1, "filename": "interruptingcow-0.4.tar.gz", "has_sig": false, "md5_digest": "3769fbf8938576b5bf9a98267c18981a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2877, "upload_time": "2012-06-02T18:28:54", "url": "https://files.pythonhosted.org/packages/3a/79/83c607c3fda88cdfebd3cac2a6a04a969dca8907500312d4d3f1b2b44ed0/interruptingcow-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "56111ee58bae18f508a342fc4ff3204c", "sha256": "6c7d3d19a3ff37e94c6e064bd2b03af09d8461ebeb10d6e7781e555af322ad1b" }, "downloads": -1, "filename": "interruptingcow-0.5.tar.gz", "has_sig": false, "md5_digest": "56111ee58bae18f508a342fc4ff3204c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3600, "upload_time": "2012-06-10T20:46:20", "url": "https://files.pythonhosted.org/packages/3e/1e/88342c5d789361e0cf269ecb1cd492fded2aac5691f2029a57a9e5ba86ff/interruptingcow-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "f31b238e72ce40239dd2275ccb73945f", "sha256": "2d65a87fb82d036d0190c772a54b7ab6f2a94d72818e4c78b207390045bd64b3" }, "downloads": -1, "filename": "interruptingcow-0.6.tar.gz", "has_sig": false, "md5_digest": "f31b238e72ce40239dd2275ccb73945f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3606, "upload_time": "2012-06-21T21:15:26", "url": "https://files.pythonhosted.org/packages/63/36/e77158cb9bdae3299cf0d26b935cbde3534163d06e111841abf845605837/interruptingcow-0.6.tar.gz" } ], "0.7": [ { "comment_text": "", "digests": { "md5": "e8b9fd6000b6507a13f0c02db11bd7d7", "sha256": "a3f40f3171d01e240d4eab70dd53de2716824da3926de4d6e14e76045706cd48" }, "downloads": -1, "filename": "interruptingcow-0.7.tar.gz", "has_sig": false, "md5_digest": "e8b9fd6000b6507a13f0c02db11bd7d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4857, "upload_time": "2017-07-29T21:56:43", "url": "https://files.pythonhosted.org/packages/b3/d4/e7f9744620b7e63b1631e30aa2320eebb6a0637b948bfd4ed7add78f03d8/interruptingcow-0.7.tar.gz" } ], "0.7rc1": [ { "comment_text": "", "digests": { "md5": "967df10810d812510973953f3bf45ffd", "sha256": "fbc4f01054a99a69471897ec33360cdc5b021efd6102f37478cebab937f14052" }, "downloads": -1, "filename": "interruptingcow-0.7rc1.tar.gz", "has_sig": false, "md5_digest": "967df10810d812510973953f3bf45ffd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4899, "upload_time": "2017-07-29T21:22:10", "url": "https://files.pythonhosted.org/packages/f9/c7/656c5e437b05c66a9fa88d830e7f213d26ac873478b728d043c52a14401f/interruptingcow-0.7rc1.tar.gz" } ], "0.8": [ { "comment_text": "", "digests": { "md5": "78162ad4fd78e5bcd353abff110dc32f", "sha256": "3e8cd5058b651e625702cba53e3b1fb76d7a5ec07ab69c52a167a9f784e3306c" }, "downloads": -1, "filename": "interruptingcow-0.8.tar.gz", "has_sig": false, "md5_digest": "78162ad4fd78e5bcd353abff110dc32f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5009, "upload_time": "2018-02-27T19:40:48", "url": "https://files.pythonhosted.org/packages/64/3a/1e58f9e38acb38d42584872150400ddafb6d669700fd9b99f079adce00f6/interruptingcow-0.8.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "78162ad4fd78e5bcd353abff110dc32f", "sha256": "3e8cd5058b651e625702cba53e3b1fb76d7a5ec07ab69c52a167a9f784e3306c" }, "downloads": -1, "filename": "interruptingcow-0.8.tar.gz", "has_sig": false, "md5_digest": "78162ad4fd78e5bcd353abff110dc32f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5009, "upload_time": "2018-02-27T19:40:48", "url": "https://files.pythonhosted.org/packages/64/3a/1e58f9e38acb38d42584872150400ddafb6d669700fd9b99f079adce00f6/interruptingcow-0.8.tar.gz" } ] }