+ def handle(self, req):
+ spawn = False
+ with self.qlk:
+ if self.timeout is not None:
+ now = start = time.time()
+ while len(self.queue) >= self.qsz:
+ self.qecond.wait(start + self.timeout - now)
+ now = time.time()
+ if now - start > self.timeout:
+ os.abort()
+ else:
+ while len(self.queue) >= self.qsz:
+ self.qecond.wait()
+ self.queue.append(req)
+ self.qfcond.notify()
+ if len(self.waiting) < 1:
+ spawn = True
+ if spawn:
+ with self.clk:
+ if len(self.current) < self.max:
+ th = reqthread(target=self.run)
+ th.registered = False
+ th.start()
+ while not th.registered:
+ self.ccond.wait()