MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / _read

Method _read

asyncpg/_testbase/fuzzer.py:258–283  ·  view source on GitHub ↗
(self, sock, n)

Source from the content-addressed store, hash-verified

256 self.proxy.connections.pop(self, None)
257
258 async def _read(self, sock, n):
259 if sock is self.client_sock and self.client_reader is not None:
260 read = self.client_reader.read(n)
261 else:
262 read = self.loop.sock_recv(sock, n)
263 read_task = asyncio.ensure_future(read)
264 conn_event_task = asyncio.ensure_future(
265 self.connectivity_loss.wait())
266
267 try:
268 await asyncio.wait(
269 [read_task, conn_event_task],
270 return_when=asyncio.FIRST_COMPLETED)
271
272 if self.connectivity_loss.is_set():
273 return None
274 else:
275 return read_task.result()
276 finally:
277 if not self.loop.is_closed():
278 if not read_task.done():
279 read_task.cancel()
280 if not conn_event_task.done():
281 conn_event_task.cancel()
282 await asyncio.gather(read_task, conn_event_task,
283 return_exceptions=True)
284
285 async def _write(self, sock, data):
286 if sock is self.client_sock and self.client_writer is not None:

Callers 2

proxy_to_backendMethod · 0.95
proxy_from_backendMethod · 0.95

Calls 3

waitMethod · 0.80
is_closedMethod · 0.80
cancelMethod · 0.45

Tested by

no test coverage detected