Prevent the metric queue from growing unbounded
This commit is contained in:
parent
cfb6e884f2
commit
b04c190ca0
1 changed files with 11 additions and 3 deletions
|
@ -1,11 +1,19 @@
|
||||||
from Queue import Queue
|
import logging
|
||||||
|
|
||||||
|
from Queue import Queue, Full
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class MetricQueue(object):
|
class MetricQueue(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._queue = Queue()
|
self._queue = Queue(10000)
|
||||||
|
|
||||||
def put(self, *args, **kwargs):
|
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):
|
def get(self):
|
||||||
return self._queue.get()
|
return self._queue.get()
|
||||||
|
|
Reference in a new issue