MCPcopy
hub / github.com/encode/httpx / __aiter__

Method __aiter__

httpx/_content.py:75–89  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

73 self._is_generator = inspect.isasyncgen(stream)
74
75 async def __aiter__(self) -> AsyncIterator[bytes]:
76 if self._is_stream_consumed and self._is_generator:
77 raise StreamConsumed()
78
79 self._is_stream_consumed = True
80 if hasattr(self._stream, "aread"):
81 # File-like interfaces should use 'aread' directly.
82 chunk = await self._stream.aread(self.CHUNK_SIZE)
83 while chunk:
84 yield chunk
85 chunk = await self._stream.aread(self.CHUNK_SIZE)
86 else:
87 # Otherwise iterate.
88 async for part in self._stream:
89 yield part
90
91
92class UnattachedStream(AsyncByteStream, SyncByteStream):

Callers

nothing calls this directly

Calls 2

StreamConsumedClass · 0.85
areadMethod · 0.45

Tested by

no test coverage detected