Prevent the metric queue from growing unbounded

This commit is contained in:
Matt Jibson 2015-08-11 16:52:05 -04:00
parent cfb6e884f2
commit b04c190ca0

View file

@ -1,11 +1,19 @@
from Queue import Queue
import logging
from Queue import Queue, Full
logger = logging.getLogger(__name__)
class MetricQueue(object):
def __init__(self):
self._queue = Queue()
self._queue = Queue(10000)
def put(self, *args, **kwargs):
self._queue.put((args, kwargs))
try:
self._queue.put_nowait((args, kwargs))
except Full:
logger.error('Metric queue full')
def get(self):
return self._queue.get()