def _extract_buffers(obj, threshold=MAX_BYTES):
buffers = []<EOL>if isinstance(obj, CannedObject) and obj.buffers:<EOL><INDENT>for i, buf in enumerate(obj.buffers):<EOL><INDENT>nbytes = _nbytes(buf)<EOL>if nbytes > threshold:<EOL><INDENT>obj.buffers[i] = None<EOL>buffers.append(buf)<EOL><DEDENT>elif isinstance(buf, memoryview):<EOL><INDENT>obj.buffers[i] = buf.tobytes()<EOL><DEDENT>elif isinstance(buf, buffer):<EOL><INDENT>obj.buffers[i] = bytes(buf)<EOL><DEDENT><DEDENT><DEDENT>return buffers<EOL>
Extract buffers larger than a certain threshold.