S3: Close filehandle of versioned keys (#5587)
This commit is contained in:
parent
80ab997010
commit
6f710189ce
@ -1455,12 +1455,10 @@ class S3Backend(BaseBackend, CloudWatchMetricProvider):
|
|||||||
def reset(self):
|
def reset(self):
|
||||||
# For every key and multipart, Moto opens a TemporaryFile to write the value of those keys
|
# For every key and multipart, Moto opens a TemporaryFile to write the value of those keys
|
||||||
# Ensure that these TemporaryFile-objects are closed, and leave no filehandles open
|
# Ensure that these TemporaryFile-objects are closed, and leave no filehandles open
|
||||||
for bucket in self.buckets.values():
|
for mp in FakeMultipart.instances:
|
||||||
for key in bucket.keys.values():
|
mp.dispose()
|
||||||
if isinstance(key, FakeKey):
|
for key in FakeKey.instances:
|
||||||
key.dispose()
|
key.dispose()
|
||||||
for mp in bucket.multiparts.values():
|
|
||||||
mp.dispose()
|
|
||||||
super().reset()
|
super().reset()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -56,6 +56,11 @@ class TestS3FileHandleClosures(TestCase):
|
|||||||
def test_overwriting_file(self):
|
def test_overwriting_file(self):
|
||||||
self.s3.put_object("my-bucket", "my-key", "b" * 10_000_000)
|
self.s3.put_object("my-bucket", "my-key", "b" * 10_000_000)
|
||||||
|
|
||||||
|
@verify_zero_warnings
|
||||||
|
def test_versioned_file(self):
|
||||||
|
self.s3.put_bucket_versioning("my-bucket", "Enabled")
|
||||||
|
self.s3.put_object("my-bucket", "my-key", "b" * 10_000_000)
|
||||||
|
|
||||||
@verify_zero_warnings
|
@verify_zero_warnings
|
||||||
def test_copy_object(self):
|
def test_copy_object(self):
|
||||||
key = self.s3.get_object("my-bucket", "my-key")
|
key = self.s3.get_object("my-bucket", "my-key")
|
||||||
|
Loading…
Reference in New Issue
Block a user