{ "info": { "author": "Adam Johnson", "author_email": "me@adamj.eu", "bugtrack_url": null, "classifiers": [ "Development Status :: 7 - Inactive", "Intended Audience :: Developers", "License :: OSI Approved :: ISC License (ISCL)", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development" ], "description": "=============\nWSGI Harakiri\n=============\n\n**Abandoned**\n\nDon't use this, it's not the best way to achieve a request timeout. You're\nprobably better off using and improving any such feature built into your wsgi\nserver, since it will terminate things more reliably.\n\n.. image:: https://img.shields.io/pypi/v/wsgi-harakiri.svg\n :target: https://pypi.python.org/pypi/wsgi-harakiri\n\n.. image:: https://img.shields.io/travis/adamchainz/wsgi-harakiri.svg\n :target: https://travis-ci.org/adamchainz/wsgi-harakiri\n\nWSGI Middleware that implements a customizable 'harakiri' like uWSGI.\n\n\nInstallation\n------------\n\nUse **pip**:\n\n.. code-block:: bash\n\n pip install wsgi-harakiri\n\nTested on Python 2.7, 3.4, and 3.5.\n\nUsage\n-----\n\nWrap your WSGI application with the middleware, for example for a Django\napplication in your ``wsgi.py``:\n\n.. code-block:: python\n\n import os\n\n from django.core.wsgi import get_wsgi_application\n\n os.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"myproject.settings\")\n\n application = get_wsgi_application()\n\n from wsgi_harakiri import HarakiriMiddleware\n\n # By default adds a request timeout of 30 seconds\n application = HarakiriMiddleware(application)\n\nYour app **must not** be running a multi-threaded server (multi-process is ok),\nand it **must** be running on a POSIX system. The ``alarm`` system call is\nused, so this **cannot** be combined with other things that use it, e.g. the\n'harakiri' functionality in uWSGI.\n\nAPI\n---\n\n``HarakiriMiddleware(application, timeout=30, on_harakiri=None, error_app=None)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWraps a WSGI application with the harakiri functionality.\n\n``application`` may be any WSGI application.\n\n``timeout`` may be any integer number of seconds, and defaults to 30.\n\n``on_harakiri`` will be called when a harakiri occurs, from inside the alarm\nfunction - it is thus suitable for logging the stack trace that lead to the\ntimeout. Its return value is ignored.\n\n``error_app`` is a second WSGI application that will be called to produce an\nerror response when a timeout occurs. The default response is a rather plain\n'500 Internal server error' with HTML '

Page load timeout

'.\n\nExample usage with all arguments:\n\n.. code-block:: python\n\n application = get_wsgi_application()\n\n from wsgi_harakiri import HarakiriMiddleware\n\n\n def harakiri_handler():\n logger.error(\"Harakiri occured\", extra={'stack': True})\n\n\n def harakiri_page(environ, start_response):\n start_response(\n '500 Internal server error',\n [('Content-Type', 'text/html')]\n )\n return [b'

Sorry, this page timed out.

']\n\n\n application = HarakiriMiddleware(\n application,\n timeout=15,\n on_harakiri=harakiri_handler,\n error_app=harakiri_page,\n )\n\n``Harakiri``\n~~~~~~~~~~~~\n\nThis is the exception that gets raised when a timeout occurs. You should\n**not** catch it anywhere in your code, however you could use it to detect when\nit happens inside a particular code path. For example:\n\n.. code-block:: python\n\n from wsgi_harakiri import Harakiri\n\n\n def find_users(search_term):\n conn = make_db_connection()\n try:\n return conn.query(search_term)\n except Harakiri:\n logger.error(\"A search timed out\", extra={'search_term': search_term})\n raise\n\n\n=======\nHistory\n=======\n\nPending Release\n---------------\n\n* New release notes here\n\n1.0.0 (2016-03-28)\n------------------\n\n* First release on PyPI, with ``HarakiriMiddleware``.", "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/adamchainz/wsgi-harakiri", "keywords": "WSGI,Harakiri", "license": "ISCL", "maintainer": null, "maintainer_email": null, "name": "wsgi-harakiri", "package_url": "https://pypi.org/project/wsgi-harakiri/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/wsgi-harakiri/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/adamchainz/wsgi-harakiri" }, "release_url": "https://pypi.org/project/wsgi-harakiri/1.0.0/", "requires_dist": null, "requires_python": null, "summary": "WSGI Middleware that implements a customizable 'harakiri' like uWSGI", "version": "1.0.0" }, "last_serial": 2082601, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "2e19d8a3b5c648b3af8b6283e8212dc4", "sha256": "b28fcdf2696bcf4d0877174c802e732072d4a0dda4702eebc921fc15da54da37" }, "downloads": -1, "filename": "wsgi_harakiri-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2e19d8a3b5c648b3af8b6283e8212dc4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5788, "upload_time": "2016-03-28T13:03:13", "url": "https://files.pythonhosted.org/packages/20/44/eb5d49be9ec0610ef8762e9d37689c8308ceac8231b01799e01aad2c81b7/wsgi_harakiri-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "247f66a80a1367454a8f3723a012f221", "sha256": "84583627bf1d0afdeae062855f78970c04b09aec80b0c51cc127ef06e4e43ada" }, "downloads": -1, "filename": "wsgi-harakiri-1.0.0.tar.gz", "has_sig": false, "md5_digest": "247f66a80a1367454a8f3723a012f221", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5457, "upload_time": "2016-03-28T13:03:20", "url": "https://files.pythonhosted.org/packages/80/34/2da6fa30cf6a516367b5a06d9f4d165c972e3fb9e335955e0de1e9ab1abc/wsgi-harakiri-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2e19d8a3b5c648b3af8b6283e8212dc4", "sha256": "b28fcdf2696bcf4d0877174c802e732072d4a0dda4702eebc921fc15da54da37" }, "downloads": -1, "filename": "wsgi_harakiri-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2e19d8a3b5c648b3af8b6283e8212dc4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5788, "upload_time": "2016-03-28T13:03:13", "url": "https://files.pythonhosted.org/packages/20/44/eb5d49be9ec0610ef8762e9d37689c8308ceac8231b01799e01aad2c81b7/wsgi_harakiri-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "247f66a80a1367454a8f3723a012f221", "sha256": "84583627bf1d0afdeae062855f78970c04b09aec80b0c51cc127ef06e4e43ada" }, "downloads": -1, "filename": "wsgi-harakiri-1.0.0.tar.gz", "has_sig": false, "md5_digest": "247f66a80a1367454a8f3723a012f221", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5457, "upload_time": "2016-03-28T13:03:20", "url": "https://files.pythonhosted.org/packages/80/34/2da6fa30cf6a516367b5a06d9f4d165c972e3fb9e335955e0de1e9ab1abc/wsgi-harakiri-1.0.0.tar.gz" } ] }