{ "info": { "author": "Christopher Welborn", "author_email": "cj@welbornprod.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "TimedOp\n=======\n\nA module to roughly measure the amount of time Python operations take.\nThere is also a ``timed_call`` function that will enforce a time limit\non function calls.\n\nExamples\n--------\n\nBasic\n~~~~~\n\n.. code:: python\n\n from timedop import TimedOp\n\n with TimedOp(label='Elapsed: ') as t:\n # Some long operation?\n busy_work()\n print(t)\n\nOutput:\n\n::\n\n Elapsed: 0.24\n\nTimed Call\n~~~~~~~~~~\n\n.. code:: python\n\n from timedop import timed_call, TimedOut\n\n def busy_work(stop, increment=1):\n \"\"\" A dummy function, to simulate some work. \"\"\"\n start = 0\n while start < stop:\n start += increment\n return start\n\n # Allow 2 seconds for busy_work() to return:\n try:\n result = timed_call(\n busy_work,\n args=(100000000000, ),\n kwargs={'increment': 2},\n timeout=2\n )\n except TimedOut as ex:\n print('Uh oh.')\n print(ex)\n else:\n # Doesn't happen on my machine.\n print(result)\n\nOutput:\n\n::\n\n Uh oh.\n Operation timed out. (busy_work(100000000000, increment=2), 2 seconds)\n\nAPI\n---\n\nTimedOp\n~~~~~~~\n\nA ``TimedOp`` is just a timer that you can ``start`` and ``stop``. You\ncan initialise a ``TimedOp`` with an optional ``label``, which will be\nused for ``str()`` or ``repr()``.\n\n.. code:: python\n\n t = TimedOp(label='Time elapsed: ').start()\n something()\n print(t.stop())\n\nA ``TimedOp`` can also be used as a context manager. The ``start``\nmethod is called on ``__enter__``, and ``stop`` is called on\n``__exit__``.\n\n.. code:: python\n\n with TimedOp(label='Elapsed: ') as t:\n something()\n # Prints the time elapsed while inside the `with` block.\n print(t)\n\nTimedOp Methods:\n^^^^^^^^^^^^^^^^\n\n- ``elapsed``: Return the number of seconds since the ``TimedOp``\n started.\n\n- ``set_format(fmt)``: Set the default format string for the elapsed\n seconds and returns ``self``. Default: ``'{:0.2f}'``\n\n- ``sleep(seconds)``: Shortcut for ``time.sleep(seconds)``\n\n- ``start``: Starts the timer, and returns ``self``.\n\n- ``stop``: Stops the timer, and returns ``self``.\n\nTimedOut\n~~~~~~~~\n\nAn exception that is raised from ``timed_call``, containing information\nabout the timed function call such as:\n\n- ``self.func``: The function object.\n- ``self.args``: The arguments provided to the function.\n- ``self.kwargs``: The keyword arguments provided to the function.\n- ``self.timeout``: The timeout that was set for the timed call.\n- ``self.formatted``: A string representing all of the above\n information. Used for ``str(TimedOut)``.\n\ntimed\\_call\n~~~~~~~~~~~\n\n.. code:: python\n\n timed_call(func, args=None, kwargs=None, timeout=DEFAULT_TIMEOUT)\n\nCalls a function (``func``), and raises ``TimedOut`` if the function\ncall takes more than ``timeout`` seconds. The default timeout is set to\n``timedop.DEFAULT_TIMEOUT`` (4 seconds).\n\nReturns the result from calling ``func(*args, **kwargs)`` unless it\ntimes out.\n\ntimed\\_call Arguments\n^^^^^^^^^^^^^^^^^^^^^\n\n- ``func``: The function to call.\n\n- ``args``: A ``list``/``tuple`` of arguments to use when calling the\n function (``func``).\n\n- ``kwargs``: A ``dict`` of keyword arguments to use when calling the\n function (``func``).\n\n- ``timeout``: The number of seconds to wait before raising a\n ``TimedOut`` exception. This is set to ``timedop.DEFAULT_SECONDS`` by\n default (4 seconds).", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/TimedOp/", "keywords": "python module library 2 3 ...", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "timedop", "package_url": "https://pypi.org/project/timedop/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/timedop/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/TimedOp/" }, "release_url": "https://pypi.org/project/timedop/0.0.7/", "requires_dist": null, "requires_python": null, "summary": "Time python operations or enforce a time limit for function calls.", "version": "0.0.7" }, "last_serial": 2501648, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "359dac9a531b503aaf4f16d8e436d93a", "sha256": "5ea0ffa2dc697934fd77e3fd0814ed4aa6854e884f9877849a9aa983beba1820" }, "downloads": -1, "filename": "timedop-0.0.2.tar.gz", "has_sig": false, "md5_digest": "359dac9a531b503aaf4f16d8e436d93a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5239, "upload_time": "2016-12-05T02:13:12", "url": "https://files.pythonhosted.org/packages/84/b4/47e835cff2df14b167ecb47f280f470355eb8f62dd94c24f96857e7eecae/timedop-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "b97ff06cafb49a2d3a80f5da21d01d6c", "sha256": "285c64722c8c1e859221d72f5b34e14f2569928e48f999fce6ba2022d0687cb5" }, "downloads": -1, "filename": "timedop-0.0.3.tar.gz", "has_sig": false, "md5_digest": "b97ff06cafb49a2d3a80f5da21d01d6c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6229, "upload_time": "2016-12-05T02:15:39", "url": "https://files.pythonhosted.org/packages/8e/a6/a94ee52e702cea59d87a3703e205dd768762b2091e768efdb5ad1ea98bf8/timedop-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "b48fde4dca77b3511d061017eb8ab8ee", "sha256": "d3d562dc4e53d383f09f94745e82bd8fd6e2707e13af5d3fbfd992a10f063b90" }, "downloads": -1, "filename": "timedop-0.0.4.tar.gz", "has_sig": false, "md5_digest": "b48fde4dca77b3511d061017eb8ab8ee", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7055, "upload_time": "2016-12-05T02:23:28", "url": "https://files.pythonhosted.org/packages/66/6a/e47f48c3dbc9b14271939b196d7d8b90dcf65820aa54b1e38320253f6d01/timedop-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "64c942678b3afb83b086c50e7a121937", "sha256": "1bded415b93353784ac63671a27bf8834002588e175d3efffbf5162bfbc93f6e" }, "downloads": -1, "filename": "timedop-0.0.5.tar.gz", "has_sig": false, "md5_digest": "64c942678b3afb83b086c50e7a121937", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7093, "upload_time": "2016-12-05T02:35:07", "url": "https://files.pythonhosted.org/packages/e7/9e/01b02bdb8b4fe9755f468884d07c5d270791a7d648af7198a5a05a62b86b/timedop-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "211ef794c7f527e90b6ccb16f2d203bc", "sha256": "806b0f11511c51c7bbced9c053c1adb7f20248a60662a7ef25302c4c6ba7502c" }, "downloads": -1, "filename": "timedop-0.0.6.tar.gz", "has_sig": false, "md5_digest": "211ef794c7f527e90b6ccb16f2d203bc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7356, "upload_time": "2016-12-06T03:11:12", "url": "https://files.pythonhosted.org/packages/6f/a7/8db6735325bb8b58e6b908cbe2d4d504739090f632230460ac1b7559fae2/timedop-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "b2a42f0df231ac32b1885019996cdff8", "sha256": "b1eee3a66526c157fbb7d0e93f324506c486a60b4b664107f519ecd0f55b36de" }, "downloads": -1, "filename": "timedop-0.0.7.tar.gz", "has_sig": false, "md5_digest": "b2a42f0df231ac32b1885019996cdff8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7405, "upload_time": "2016-12-06T03:15:07", "url": "https://files.pythonhosted.org/packages/7e/1b/da7f3963158ac98936f55345976f65a2c66ced7f93c29fc26185d851fca7/timedop-0.0.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b2a42f0df231ac32b1885019996cdff8", "sha256": "b1eee3a66526c157fbb7d0e93f324506c486a60b4b664107f519ecd0f55b36de" }, "downloads": -1, "filename": "timedop-0.0.7.tar.gz", "has_sig": false, "md5_digest": "b2a42f0df231ac32b1885019996cdff8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7405, "upload_time": "2016-12-06T03:15:07", "url": "https://files.pythonhosted.org/packages/7e/1b/da7f3963158ac98936f55345976f65a2c66ced7f93c29fc26185d851fca7/timedop-0.0.7.tar.gz" } ] }