Whole file
cdrx/faktory_python_worker
The author described this change as “Ensure all data is sent and raise an error when connection is reset”. It counts as a record because the checks below fail on the code as it stood at f6ca4c65d and pass on d1dc6ccea, with nothing else changed between the two runs.
Projectcdrx/faktory_python_worker
Fix saved2021-12-10
Sharing licenceBSD-3-Clause · LICENSE
Change size+6 −1
What the code was meant to do, written into the code itself as a save note
Ensure all data is sent and raise an error when connection is reset
The change
| 320 | 320 | s = "{} {}".format(s, json.dumps(data)) | |
| 321 | 321 | else: | |
| 322 | 322 | s = "{} {}".format(s, data) | |
| 323 | - | self.socket.send(str.encode(s + "\r\n")) | |
| 323 | + | buffer = str.encode(s + "\r\n") | |
| 324 | + | while len(buffer): | |
| 325 | + | sent = self.socket.send(buffer) | |
| 326 | + | if sent == 0: | |
| 327 | + | raise FaktoryConnectionResetError | |
| 328 | + | buffer = buffer[sent:] | |
| 324 | 329 | ||
| 325 | 330 | def disconnect(self): | |
| 326 | 331 | self.log.info("Disconnected") |
The check that tells the two apart
fail→pass·tests/test_proto.py::TestConnectionReply::test_send_zero_raises_error[None]
fail→pass·tests/test_proto.py::TestConnectionReply::test_send_zero_raises_error[data2]
fail→pass·tests/test_proto.py::TestConnectionReply::test_send_zero_raises_error[string
fail→pass·tests/test_proto.py::TestConnectionReply::test_sends_until_out_of_data[None]
fail→pass·tests/test_proto.py::TestConnectionReply::test_sends_until_out_of_data[data2]
fail→pass·tests/test_proto.py::TestConnectionReply::test_sends_until_out_of_data[string
Check file tests/test_proto.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itf6ca4c65d3cbe5c79fa521b9d01f1d73f909e502
Broken version dated2021-03-23
Modulefaktory._proto
Units changedConnection
Fingerprint0dab870e1b1b7876
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.