From 37eb65c937d27b6579118aa2a3b761f0f26f3813 Mon Sep 17 00:00:00 2001 From: Kent Slaney Date: Sat, 27 Jan 2024 13:05:54 -0800 Subject: [PATCH] add py FIFO thread pool --- misc/runbench.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/misc/runbench.py b/misc/runbench.py index 2362f550..47fafc8d 100644 --- a/misc/runbench.py +++ b/misc/runbench.py @@ -340,7 +340,7 @@ def reserve(self): mc = self.clients.get(False) self.semaphore.put(1) except: - channel = Queue() + channel = Queue(1) self.waiting.put(channel) self.semaphore.put(1) channel.get() @@ -349,9 +349,9 @@ def reserve(self): try: yield mc finally: + self.semaphore.get() self.clients.put(mc) try: - self.semaphore.get() self.waiting.get(False).put(1) except: self.semaphore.put(1) @@ -412,7 +412,7 @@ def reserve(self): threads=NTHREADS ), Participant( - # name='libmc(md5 / ketama / nodelay / nonblocking / py thread pool, from douban)', + # name='libmc(md5 / ketama / nodelay / nonblocking / py FIFO thread pool, from douban)', name='libmc (py FIFO thread pool)', factory=lambda: Prefix(FIFOThreadPool(**libmc_kwargs), 'libmc5'), threads=NTHREADS @@ -471,7 +471,6 @@ def loop(sw): logger.info(u'%76s: %s', participant.name, total) exceptions[i].append(None) except Exception as e: - raise logger.info(u'%76s: %s', participant.name, "failed") exceptions[i].append(e) last_fn = fn