Read the specified number of bytes from sock. Keep trying until we either get the desired amount, or we hit EOF. A Timeout exception will be raised if the operation is not completed by the expiration time.
(sock, count, expiration)
| 1077 | |
| 1078 | |
| 1079 | def _net_read(sock, count, expiration): |
| 1080 | """Read the specified number of bytes from sock. Keep trying until we |
| 1081 | either get the desired amount, or we hit EOF. |
| 1082 | A Timeout exception will be raised if the operation is not completed |
| 1083 | by the expiration time. |
| 1084 | """ |
| 1085 | s = b"" |
| 1086 | while count > 0: |
| 1087 | try: |
| 1088 | n = sock.recv(count) |
| 1089 | if n == b"": |
| 1090 | raise EOFError("EOF") |
| 1091 | count -= len(n) |
| 1092 | s += n |
| 1093 | except (BlockingIOError, ssl.SSLWantReadError): |
| 1094 | _wait_for_readable(sock, expiration) |
| 1095 | except ssl.SSLWantWriteError: # pragma: no cover |
| 1096 | _wait_for_writable(sock, expiration) |
| 1097 | return s |
| 1098 | |
| 1099 | |
| 1100 | def _net_write(sock, data, expiration): |
no test coverage detected
searching dependent graphs…