{ "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 '