Fix high memory usage is USM client when uploading a file
This commit ensures that software client will not load the entire ISO file into memory, avoids memory spikes. Test Plan: PASS - software --os-region-name SystemController upload <iso file> <sig file> files without memory spikes PASS - software upload --local <iso file> <sig file> without memory spikes Closes-Bug: 2085380 Change-Id: If84d6b78269d6bc2be4e325dacc4be9556576c2a Signed-off-by: Wallysson Silva <wallysson.silva@windriver.com>
This commit is contained in:
parent
5ae2b5099e
commit
69c20dfebf
@ -4,6 +4,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
import contextlib
|
||||
import os
|
||||
import re
|
||||
import signal
|
||||
@ -105,14 +106,14 @@ class ReleaseManager(base.Manager):
|
||||
print("No file to be uploaded.")
|
||||
return 1
|
||||
|
||||
for software_file in valid_files:
|
||||
with open(software_file, 'rb') as file:
|
||||
data_content = file.read()
|
||||
to_upload_files[software_file] = (software_file, data_content)
|
||||
with contextlib.ExitStack() as stack:
|
||||
for software_file in valid_files:
|
||||
file = stack.enter_context(open(software_file, 'rb'))
|
||||
to_upload_files[software_file] = (software_file, file)
|
||||
|
||||
encoder = MultipartEncoder(fields=to_upload_files)
|
||||
headers = {'Content-Type': encoder.content_type}
|
||||
return self._create_multipart(path, body=encoder, headers=headers)
|
||||
encoder = MultipartEncoder(fields=to_upload_files)
|
||||
headers = {'Content-Type': encoder.content_type}
|
||||
return self._create_multipart(path, body=encoder, headers=headers)
|
||||
|
||||
def upload_dir(self, args):
|
||||
# arg.release is a list
|
||||
|
Loading…
x
Reference in New Issue
Block a user