Dolda2000 GitWeb
/
ashd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib: Allow reception of mtstdopen info structure.
[ashd.git]
/
python3
/
ashd
/
serve.py
diff --git
a/python3/ashd/serve.py
b/python3/ashd/serve.py
index
0eddc09
..
e156cd6
100644
(file)
--- a/
python3/ashd/serve.py
+++ b/
python3/ashd/serve.py
@@
-204,6
+204,8
@@
class threadpool(handler):
self.ccond = threading.Condition(self.clk)
self.queue = collections.deque()
self.waiting = set()
self.ccond = threading.Condition(self.clk)
self.queue = collections.deque()
self.waiting = set()
+ self.waitlimit = 5
+ self.wlstart = 0.0
self.qlk = threading.Lock()
self.qcond = threading.Condition(self.qlk)
self.max = max
self.qlk = threading.Lock()
self.qcond = threading.Condition(self.qlk)
self.max = max
@@
-222,7
+224,7
@@
class threadpool(handler):
return ret
def handle(self, req):
return ret
def handle(self, req):
- s
tart
= False
+ s
pawn
= False
with self.qlk:
if self.timeout is not None:
now = start = time.time()
with self.qlk:
if self.timeout is not None:
now = start = time.time()
@@
-237,8
+239,8
@@
class threadpool(handler):
self.queue.append(req)
self.qcond.notify()
if len(self.waiting) < 1:
self.queue.append(req)
self.qcond.notify()
if len(self.waiting) < 1:
- s
tart
= True
- if s
tart
:
+ s
pawn
= True
+ if s
pawn
:
with self.clk:
if len(self.current) < self.max:
th = reqthread(target=self.run)
with self.clk:
if len(self.current) < self.max:
th = reqthread(target=self.run)
@@
-275,9
+277,15
@@
class threadpool(handler):
start = now = time.time()
with self.qlk:
while len(self.queue) < 1:
start = now = time.time()
with self.qlk:
while len(self.queue) < 1:
+ if len(self.waiting) >= self.waitlimit and now - self.wlstart >= timeout:
+ return
self.waiting.add(th)
self.waiting.add(th)
- self.qcond.wait(start + timeout - now)
- self.waiting.remove(th)
+ try:
+ if len(self.waiting) == self.waitlimit:
+ self.wlstart = now
+ self.qcond.wait(start + timeout - now)
+ finally:
+ self.waiting.remove(th)
now = time.time()
if now - start > timeout:
return
now = time.time()
if now - start > timeout:
return
@@
-292,7
+300,7
@@
class threadpool(handler):
def close(self):
while True:
def close(self):
while True:
- with self.lk:
+ with self.
c
lk:
if len(self.current) > 0:
th = next(iter(self.current))
else:
if len(self.current) > 0:
th = next(iter(self.current))
else: