Dolda2000 GitWeb
/
ashd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
httimed: Prevent lossage of buffered requests during shutdown.
[ashd.git]
/
python3
/
ashd
/
serve.py
diff --git
a/python3/ashd/serve.py
b/python3/ashd/serve.py
index
ebee436
..
db68a5f
100644
(file)
--- a/
python3/ashd/serve.py
+++ b/
python3/ashd/serve.py
@@
-108,6
+108,16
@@
class single(handler):
finally:
req.close()
finally:
req.close()
+def dbg(*a):
+ f = True
+ for o in a:
+ if not f:
+ sys.stderr.write(" ")
+ sys.stderr.write(str(a))
+ f = False
+ sys.stderr.write("\n")
+ sys.stderr.flush()
+
class freethread(handler):
cname = "free"
class freethread(handler):
cname = "free"
@@
-142,8
+152,9
@@
class freethread(handler):
while len(self.current) >= self.max:
self.tcond.wait()
th = reqthread(target=self.run, args=[req])
while len(self.current) >= self.max:
self.tcond.wait()
th = reqthread(target=self.run, args=[req])
+ th.registered = False
th.start()
th.start()
- while
th.is_alive() and th not in self.current
:
+ while
not th.registered
:
self.tcond.wait()
def run(self, req):
self.tcond.wait()
def run(self, req):
@@
-151,6
+162,7
@@
class freethread(handler):
th = threading.current_thread()
with self.lk:
self.current.add(th)
th = threading.current_thread()
with self.lk:
self.current.add(th)
+ th.registered = True
self.tcond.notify_all()
try:
env = req.mkenv()
self.tcond.notify_all()
try:
env = req.mkenv()
@@
-212,8
+224,9
@@
class resplex(handler):
while len(self.current) >= self.max:
self.tcond.wait()
th = reqthread(target=self.handle1, args=[req])
while len(self.current) >= self.max:
self.tcond.wait()
th = reqthread(target=self.handle1, args=[req])
+ th.registered = False
th.start()
th.start()
- while
th.is_alive() and th not in self.current
:
+ while
not th.registered
:
self.tcond.wait()
def handle1(self, req):
self.tcond.wait()
def handle1(self, req):
@@
-221,6
+234,7
@@
class resplex(handler):
th = threading.current_thread()
with self.lk:
self.current.add(th)
th = threading.current_thread()
with self.lk:
self.current.add(th)
+ th.registered = True
self.tcond.notify_all()
try:
env = req.mkenv()
self.tcond.notify_all()
try:
env = req.mkenv()