added Queue subclass where put_nowait honors mutex lock, and that can be flushed
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import signal
|
||||
|
||||
from threading import Thread, Event
|
||||
from queue import Queue, Full
|
||||
from .prodqueue import ProdQueue, Full, Locked
|
||||
|
||||
|
||||
def prepend_signal(sig, func):
|
||||
@ -38,7 +38,7 @@ class ProdThread:
|
||||
self.func = func
|
||||
|
||||
self.thread = None
|
||||
self.queue = Queue(maxsize=maxsize)
|
||||
self.queue = ProdQueue(maxsize=maxsize)
|
||||
self.get = self.queue.get
|
||||
|
||||
self.running = Event()
|
||||
@ -58,7 +58,7 @@ class ProdThread:
|
||||
for data in gen:
|
||||
try:
|
||||
self.queue.put_nowait(data)
|
||||
except Full:
|
||||
except (Full, Locked):
|
||||
pass
|
||||
self.running.clear()
|
||||
|
||||
|
Reference in New Issue
Block a user