python: Properly abort when over request limit.
authorFredrik Tolf <fredrik@dolda2000.com>
Sat, 19 Jan 2013 00:17:49 +0000 (01:17 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Sat, 19 Jan 2013 00:17:49 +0000 (01:17 +0100)
python/ashd-wsgi
python/ashd/serve.py
python3/ashd-wsgi3
python3/ashd/serve.py

index 807fe2b..01c158f 100755 (executable)
@@ -146,7 +146,7 @@ def mkenv(req):
     return env
 
 if reqlimit != 0:
-    guard = ashd.serve.calllimiter(reqlimit).call
+    guard = ashd.serve.abortlimiter(reqlimit).call
 else:
     guard = lambda fun: fun()
 
index 4d5d9ca..14170d7 100644 (file)
@@ -1,4 +1,4 @@
-import threading, time, logging
+import os, threading, time, logging
 
 log = logging.getLogger("ashd.serve")
 seq = 1
@@ -125,3 +125,8 @@ class calllimiter(object):
             return target()
         finally:
             self.__exit__()
+
+class abortlimiter(calllimiter):
+    def waited(self, time):
+        if time > 10:
+            os.abort()
index db54e6e..ba7038d 100755 (executable)
@@ -146,7 +146,7 @@ def mkenv(req):
     return env
 
 if reqlimit != 0:
-    guard = ashd.serve.calllimiter(reqlimit).call
+    guard = ashd.serve.abortlimiter(reqlimit).call
 else:
     guard = lambda fun: fun()
 
index 9f9fe7f..fe839a2 100644 (file)
@@ -1,4 +1,4 @@
-import threading, time, logging
+import os, threading, time, logging
 
 log = logging.getLogger("ashd.serve")
 seq = 1
@@ -113,3 +113,8 @@ class calllimiter(object):
     def call(self, target):
         with self:
             return target()
+
+class abortlimiter(calllimiter):
+    def waited(self, time):
+        if time > 10:
+            os.abort()