'Create a new buffer pool.
Arguments:
memory (int): maximum memory that this buffer pool can allocate
poolable_size (int): memory size per buffer to cache in the free
list rather than deallocating'

def __init__(self, memory, poolable_size, metrics=None, metric_group_prefix='producer-metrics'):

    self._poolable_size = poolable_size
    self._lock = threading.RLock()
    buffers = (int((memory / poolable_size)) if poolable_size else 0)
    self._free = collections.deque([io.BytesIO() for _ in range(buffers)])
    self._waiters = collections.deque()
    self.wait_time = None
    if metrics:
        self.wait_time = metrics.sensor('bufferpool-wait-time')
        self.wait_time.add(metrics.metric_name('bufferpool-wait-ratio', metric_group_prefix, 'The    fraction    of    time    an    appender    waits    for    space    allocation.'), Rate())
