awslabs / aws-crt-python

Python bindings for the AWS Common Runtime
Apache License 2.0
87 stars 43 forks source link

Fix bug when S3Request is GC'd before download completes #506

Closed graebm closed 11 months ago

graebm commented 12 months ago

Issue: I discovered that, if you drop the reference to an S3Request before the operation completes and it's downloading using recv_filepath, then everything looks like it succeeds but you end up with a 0 byte file on disk.

Description of changes: Ensure the file isn't closed until the operation is complete.

Most of our code was careful to keep things alive until the operation was complete. But for whatever reason we put the file-closing code in the wrong place.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.