Skip to content

Commit 4546f23

Browse files
committed
address review
1 parent d9e65b6 commit 4546f23

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pymongo/network_layer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,12 +525,13 @@ def get_buffer(self, sizehint: int) -> memoryview:
525525
either no data remains or an empty buffer is returned.
526526
"""
527527
# Reuse the active buffer if it has space.
528+
# Allocate a bit more than the max response size for an AWS KMS response.
529+
sizehint = max(sizehint, 16384)
528530
if len(self._buffers):
529531
buffer = self._buffers[-1]
530532
if len(buffer.buffer) - buffer.end_index > sizehint:
531533
return buffer.buffer[buffer.end_index :]
532-
# Allocate a bit more than the max response size for an AWS KMS response.
533-
buffer = KMSBuffer(memoryview(bytearray(16384)), 0, 0)
534+
buffer = KMSBuffer(memoryview(bytearray(sizehint)), 0, 0)
534535
self._buffers.append(buffer)
535536
return buffer.buffer
536537

0 commit comments

Comments
 (0)