diff --git a/awscrt/aio/http.py b/awscrt/aio/http.py index d37bec401..b362f449f 100644 --- a/awscrt/aio/http.py +++ b/awscrt/aio/http.py @@ -295,7 +295,8 @@ def _on_body(self, chunk: bytes) -> None: """Process body chunk on the correct event loop thread.""" if self._chunk_futures: future = self._chunk_futures.popleft() - future.set_result(chunk) + if not future.done(): + future.set_result(chunk) else: self._received_chunks.append(chunk) @@ -309,7 +310,8 @@ def _on_complete(self, error_code: int) -> None: # Resolve all pending chunk futures with an empty string to indicate end of stream while self._chunk_futures: future = self._chunk_futures.popleft() - future.set_result("") + if not future.done(): + future.set_result("") async def _set_request_body_generator(self, body_iterator: AsyncIterator[bytes]): ...