Dolda2000 GitWeb
/
ashd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build: Rename configure.in according to autoconf standards.
[ashd.git]
/
python3
/
ashd
/
serve.py
diff --git
a/python3/ashd/serve.py
b/python3/ashd/serve.py
index
7811f66
..
0927710
100644
(file)
--- a/
python3/ashd/serve.py
+++ b/
python3/ashd/serve.py
@@
-75,8
+75,10
@@
class handler(object):
def handle(self, request):
raise Exception()
def ckflush(self, req):
def handle(self, request):
raise Exception()
def ckflush(self, req):
+ p = select.poll()
+ p.register(req, select.POLLOUT)
while len(req.buffer) > 0:
while len(req.buffer) > 0:
-
rls, wls, els = select.select([], [req], [req]
)
+
p.poll(
)
req.flush()
def close(self):
pass
req.flush()
def close(self):
pass
@@
-207,7
+209,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
@@
-224,23
+227,23
@@
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()
while len(self.queue) >= self.qsz:
with self.qlk:
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:
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)
@@
-283,13
+286,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: