Dolda2000 GitWeb
/
ashd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
892b206
)
python3: Fixed some threadpool handler bugs.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Mon, 9 Jan 2017 05:58:37 +0000
(06:58 +0100)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Mon, 9 Jan 2017 05:58:37 +0000
(06:58 +0100)
python3/ashd/serve.py
patch
|
blob
|
blame
|
history
diff --git
a/python3/ashd/serve.py
b/python3/ashd/serve.py
index
e156cd6
..
87f60a0
100644
(file)
--- a/
python3/ashd/serve.py
+++ b/
python3/ashd/serve.py
@@
-207,7
+207,8
@@
class threadpool(handler):
self.waitlimit = 5
self.wlstart = 0.0
self.qlk = threading.Lock()
self.waitlimit = 5
self.wlstart = 0.0
self.qlk = threading.Lock()
- self.qcond = threading.Condition(self.qlk)
+ self.qfcond = threading.Condition(self.qlk)
+ self.qecond = threading.Condition(self.qlk)
self.max = max
self.qsz = qsz
self.timeout = timeout
self.max = max
self.qsz = qsz
self.timeout = timeout
@@
-229,15
+230,15
@@
class threadpool(handler):
if self.timeout is not None:
now = start = time.time()
while len(self.queue) >= self.qsz:
if self.timeout is not None:
now = start = time.time()
while len(self.queue) >= self.qsz:
- self.qcond.wait(start + self.timeout - now)
+ self.q
e
cond.wait(start + self.timeout - now)
now = time.time()
if now - start > self.timeout:
os.abort()
else:
now = time.time()
if now - start > self.timeout:
os.abort()
else:
- while len(self.
current
) >= self.qsz:
- self.qcond.wait()
+ while len(self.
queue
) >= self.qsz:
+ self.q
e
cond.wait()
self.queue.append(req)
self.queue.append(req)
- self.qcond.notify()
+ self.q
f
cond.notify()
if len(self.waiting) < 1:
spawn = True
if spawn:
if len(self.waiting) < 1:
spawn = True
if spawn:
@@
-283,13
+284,14
@@
class threadpool(handler):
try:
if len(self.waiting) == self.waitlimit:
self.wlstart = now
try:
if len(self.waiting) == self.waitlimit:
self.wlstart = now
- self.qcond.wait(start + timeout - now)
+ self.q
f
cond.wait(start + timeout - now)
finally:
self.waiting.remove(th)
now = time.time()
if now - start > timeout:
return
req = self.queue.popleft()
finally:
self.waiting.remove(th)
now = time.time()
if now - start > timeout:
return
req = self.queue.popleft()
+ self.qecond.notify()
try:
self.handle1(req)
finally:
try:
self.handle1(req)
finally: