|
20 | 20 | from bson import DEFAULT_CODEC_OPTIONS |
21 | 21 | from bson.py3compat import u, itervalues |
22 | 22 | from pymongo import auth, helpers, thread_util |
| 23 | +from pymongo.common import MAX_MESSAGE_SIZE |
23 | 24 | from pymongo.errors import (AutoReconnect, |
24 | 25 | ConnectionFailure, |
25 | 26 | ConfigurationError, |
@@ -165,7 +166,8 @@ def __init__(self, sock, pool, ismaster, address): |
165 | 166 | self.is_writable = ismaster.is_writable if ismaster else None |
166 | 167 | self.max_wire_version = ismaster.max_wire_version if ismaster else None |
167 | 168 | self.max_bson_size = ismaster.max_bson_size if ismaster else None |
168 | | - self.max_message_size = ismaster.max_message_size if ismaster else None |
| 169 | + self.max_message_size = ( |
| 170 | + ismaster.max_message_size if ismaster else MAX_MESSAGE_SIZE) |
169 | 171 | self.max_write_batch_size = ( |
170 | 172 | ismaster.max_write_batch_size if ismaster else None) |
171 | 173 |
|
@@ -238,7 +240,8 @@ def receive_message(self, operation, request_id): |
238 | 240 | If any exception is raised, the socket is closed. |
239 | 241 | """ |
240 | 242 | try: |
241 | | - return receive_message(self.sock, operation, request_id) |
| 243 | + return receive_message( |
| 244 | + self.sock, operation, request_id, self.max_message_size) |
242 | 245 | except BaseException as error: |
243 | 246 | self._raise_connection_failure(error) |
244 | 247 |
|
|
0 commit comments