From d74928fa0f787959ea048171e60ca8a3ad4dea93 Mon Sep 17 00:00:00 2001 From: "roberto@quantal64" Date: Sat, 2 Jun 2012 13:46:37 +0200 Subject: [PATCH] added @harakiri decorator for new uwsgi.set_user_harakiri option --- uwsgidecorators.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/uwsgidecorators.py b/uwsgidecorators.py index 26a4a092..89c1cc98 100644 --- a/uwsgidecorators.py +++ b/uwsgidecorators.py @@ -319,3 +319,19 @@ class thread(object): t.daemon = True t.start() return self.f + + +class harakiri(object): + + def __init__(self, seconds): + self.s = seconds + + def real_call(self, *args): + uwsgi.set_user_harakiri(self.s) + r = self.f(*args) + uwsgi.set_user_harakiri(0) + return r + + def __call__(self, f): + self.f = f + return self.real_call