python: Added some SCGI fixes apparently necessary for Jython.
authorFredrik Tolf <fredrik@dolda2000.com>
Wed, 8 Aug 2012 06:37:51 +0000 (08:37 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Wed, 8 Aug 2012 06:41:52 +0000 (08:41 +0200)
python/ashd/scgi.py
python3/ashd/scgi.py

index 95325f2..f7ba3a8 100644 (file)
@@ -37,7 +37,8 @@ def readhead(sk):
 class reqthread(threading.Thread):
     def __init__(self, sk, handler):
         super(reqthread, self).__init__(name = "SCGI request handler")
-        self.sk = sk.dup().makefile("r+")
+        self.bsk = sk.dup()
+        self.sk = self.bsk.makefile("r+")
         self.handler = handler
 
     def run(self):
@@ -46,6 +47,7 @@ class reqthread(threading.Thread):
             self.handler(head, self.sk)
         finally:
             self.sk.close()
+            self.bsk.close()
 
 def handlescgi(sk, handler):
     t = reqthread(sk, handler)
index a06267f..8fa5767 100644 (file)
@@ -37,7 +37,8 @@ def readhead(sk):
 class reqthread(threading.Thread):
     def __init__(self, sk, handler):
         super(reqthread, self).__init__(name = "SCGI request handler")
-        self.sk = sk.dup().makefile("rwb")
+        self.bsk = sk.dup()
+        self.sk = self.bsk.makefile("rwb")
         self.handler = handler
 
     def run(self):
@@ -46,6 +47,7 @@ class reqthread(threading.Thread):
             self.handler(head, self.sk)
         finally:
             self.sk.close()
+            self.bsk.close()
 
 def handlescgi(sk, handler):
     t = reqthread(sk, handler)