@@ -119,14 +119,17 @@ def upload( # pylint:disable=too-many-locals,too-many-arguments
119119 # upload the file to s3
120120 log .debug ("Uploading the json file" )
121121
122- with tempfile .NamedTemporaryFile () as data_file :
123- # pylint:disable=protected-access
124- json_string = simulation ._json_string (data_file = data_file .name )
125- if data_file .name in json_string :
126- # Upload the extra data file if needed
127- json_string .replace (data_file .name , DATA_FILE_NAME )
128- upload_file (task_id , data_file .name , DATA_FILE_NAME )
129- upload_string (task_id , json_string , SIM_FILE_NAME )
122+ # pylint:disable=consider-using-with
123+ data_file = tempfile .NamedTemporaryFile ()
124+ # data_file will be reopened and closed in _json_string
125+ data_file .close ()
126+ # pylint:disable=protected-access
127+ json_string = simulation ._json_string (data_file = data_file .name )
128+ if data_file .name in json_string :
129+ # Upload the extra data file if needed
130+ json_string .replace (data_file .name , DATA_FILE_NAME )
131+ upload_file (task_id , data_file .name , DATA_FILE_NAME )
132+ upload_string (task_id , json_string , SIM_FILE_NAME )
130133
131134 # log the url for the task in the web UI
132135 log .debug (f"{ DEFAULT_CONFIG .website_endpoint } /folders/{ folder .projectId } /tasks/{ task_id } " )
0 commit comments