Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close request when initial response fails and propagate error #454

Merged
merged 3 commits into from
Mar 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -286,9 +286,9 @@ def _classify_error(
request_future, response_future,
)
except Exception as e:
if request_future is not None and not request_future.done:
if request_future is not None and not request_future.done():
request_future.set_exception($4T(e))
if response_future is not None and not response_future.done:
if response_future is not None and not response_future.done():
response_future.set_exception($4T(e))

# Make sure every exception that we throw is an instance of $4T so
7 changes: 6 additions & 1 deletion packages/smithy-http/src/smithy_http/aio/crt.py
Original file line number Diff line number Diff line change
@@ -251,7 +251,12 @@ async def send(
crt_stream.completion_future.add_done_callback(
partial(self._close_input_body, body=crt_body)
)
return await response_factory.await_response()

response = await response_factory.await_response()
if response.status != 200 and response.status >= 300:
await close(crt_body)

return response

def _close_input_body(
self, future: ConcurrentFuture[int], *, body: "BufferableByteStream | BytesIO"