X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=blobdiff_plain;f=python%2Fashd%2Fserve.py;h=3de58616800d155a17ef8e0acadf58edf4d07456;hp=a025cee4de1e6342ccb5718383b38d037aea0919;hb=6e8b9b9d6d043ecbcaeb8ef807bd9648424aedd7;hpb=9c38d6e8568186c47103a9980235595b1962c081 diff --git a/python/ashd/serve.py b/python/ashd/serve.py index a025cee..3de5861 100644 --- a/python/ashd/serve.py +++ b/python/ashd/serve.py @@ -75,8 +75,10 @@ class handler(object): def handle(self, request): raise Exception() def ckflush(self, req): + p = select.poll() + p.register(req, select.POLLOUT) while len(req.buffer) > 0: - rls, wls, els = select.select([], [req], [req]) + p.poll() req.flush() def close(self): pass @@ -142,15 +144,17 @@ class freethread(handler): while len(self.current) >= self.max: self.tcond.wait() th = reqthread(target=self.run, args=[req]) + th.registered = False th.start() - while th.is_alive() and th not in self.current: - self.tcond.wait(1) + while not th.registered: + self.tcond.wait() def run(self, req): try: th = threading.current_thread() with self.lk: self.current.add(th) + th.registered = True self.tcond.notify_all() try: env = req.mkenv() @@ -212,15 +216,17 @@ class resplex(handler): while len(self.current) >= self.max: self.tcond.wait() th = reqthread(target=self.handle1, args=[req]) + th.registered = False th.start() - while th.is_alive() and th not in self.current: - self.tcond.wait(1) + while not th.registered: + self.tcond.wait() def handle1(self, req): try: th = threading.current_thread() with self.lk: self.current.add(th) + th.registered = True self.tcond.notify_all() try: env = req.mkenv()