Skip to content

Commit f5cbce0

Browse files
committed
PYTHON-4493 Remove unused buffer size arg, await future in close()
1 parent a8c9fc1 commit f5cbce0

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

pymongo/network_layer.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ def recv_into(self, buffer: bytes) -> int:
466466

467467

468468
class PyMongoProtocol(BufferedProtocol):
469-
def __init__(self, timeout: Optional[float] = None, buffer_size: int = 2**10):
469+
def __init__(self, timeout: Optional[float] = None):
470470
self.transport: Transport = None # type: ignore[assignment]
471471
# Each message is reader in 2-3 parts: header, compression header, and message body
472472
# The message buffer is allocated after the header is read.
@@ -655,13 +655,10 @@ def connection_lost(self, exc: Exception | None) -> None:
655655
self._done_messages.append(msg)
656656

657657
if not self._closed.done():
658-
if exc is None:
659-
self._closed.set_result(None)
660-
else:
661-
self._closed.set_exception(exc)
658+
self._closed.set_result(None)
662659

663660
async def wait_closed(self) -> None:
664-
await asyncio.wait([self._closed])
661+
await self._closed
665662

666663

667664
async def async_sendall(conn: PyMongoProtocol, buf: bytes) -> None:

pymongo/pool_shared.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ async def _configured_protocol_interface(
337337
if ssl_context is None:
338338
return AsyncNetworkingInterface(
339339
await asyncio.get_running_loop().create_connection(
340-
lambda: PyMongoProtocol(timeout=timeout, buffer_size=2**16), sock=sock
340+
lambda: PyMongoProtocol(timeout=timeout), sock=sock
341341
)
342342
)
343343

@@ -346,7 +346,7 @@ async def _configured_protocol_interface(
346346
# We have to pass hostname / ip address to wrap_socket
347347
# to use SSLContext.check_hostname.
348348
transport, protocol = await asyncio.get_running_loop().create_connection( # type: ignore[call-overload]
349-
lambda: PyMongoProtocol(timeout=timeout, buffer_size=2**14),
349+
lambda: PyMongoProtocol(timeout=timeout),
350350
sock=sock,
351351
server_hostname=host,
352352
ssl=ssl_context,

0 commit comments

Comments
 (0)