Receive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by nbytes.
(self, sock, n)
| 369 | return self._remove_writer(fd) |
| 370 | |
| 371 | async def sock_recv(self, sock, n): |
| 372 | """Receive data from the socket. |
| 373 | |
| 374 | The return value is a bytes object representing the data received. |
| 375 | The maximum amount of data to be received at once is specified by |
| 376 | nbytes. |
| 377 | """ |
| 378 | base_events._check_ssl_socket(sock) |
| 379 | if self._debug and sock.gettimeout() != 0: |
| 380 | raise ValueError("the socket must be non-blocking") |
| 381 | try: |
| 382 | return sock.recv(n) |
| 383 | except (BlockingIOError, InterruptedError): |
| 384 | pass |
| 385 | fut = self.create_future() |
| 386 | fd = sock.fileno() |
| 387 | self._ensure_fd_no_transport(fd) |
| 388 | handle = self._add_reader(fd, self._sock_recv, fut, sock, n) |
| 389 | fut.add_done_callback( |
| 390 | functools.partial(self._sock_read_done, fd, handle=handle)) |
| 391 | return await fut |
| 392 | |
| 393 | def _sock_read_done(self, fd, fut, handle=None): |
| 394 | if handle is None or not handle.cancelled(): |
nothing calls this directly
no test coverage detected