-
Type:
Task
-
Resolution: Done
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
Python Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Context
The handling of socket.timeout errors in receive_message currently looks like this:
if deadline is not None: short_timeout = min(max(deadline - time.monotonic(), 0), _POLL_TIMEOUT) else: short_timeout = _POLL_TIMEOUT conn.set_conn_timeout(short_timeout) chunk_length = conn.conn.recv_into(mv[bytes_read:]) ... except socket.timeout: if conn.cancel_context.cancelled: raise _OperationCancelled("operation cancelled") from None if _PYPY: # We reached the true deadline. raise continue ...
This results in the driver attempting to read the socket an additional time once deadline - time.monotonic() is less than zero, meaning the deadline has already been reached. This can result in test failures such as PYTHON-4987, where the additional read is performed after an expected timeout instead of the timeout being raised as expected.
Definition of done
The driver should re-raise socket.timeout errors if the deadline has already been exceeded.
Pitfalls
N/A,
- fixes
-
PYTHON-4987 test.test_transactions_unified.TestUnifiedErrorLabelsBlockConnection.test_add_RetryableWriteError_and_UnknownTransactionCommitResult_labels_to_connection_errors
-
- Backlog
-