- Make the layer going over the estimated size raise an exception

- Add a heuristic for estimating the layer size if it is 0
- Add a method where we can add a custom defined map of image -> size
This commit is contained in:
Joseph Schorr 2014-09-29 12:54:22 -04:00
parent 297c8ad29c
commit 746936ce66
4 changed files with 37 additions and 35 deletions

View file

@ -40,7 +40,11 @@ class QueueProcess(object):
def _run(get_producer, queues, chunk_size, args):
producer = get_producer(*args)
while True:
data = producer(chunk_size) or None
try:
data = producer(chunk_size) or None
except Exception as ex:
data = ex
for queue in queues:
try:
queue.put(data, block=True, timeout=10)
@ -48,7 +52,7 @@ def _run(get_producer, queues, chunk_size, args):
# One of the listeners stopped listening.
return
if data is None:
if data is None or isinstance(data, Exception):
break
# Important! This allows the thread that writes the queue data to the pipe