简体   繁体   中英

Boto3 s3 python upload_file retrying repeatedly

My process

  1. s3 file upload triggers lambda function
  2. lambda function edits the doc
  3. save document object to tmp folder
  4. upload to s3 output folder as a file

Everything works and there's no error but the file is uploaded to the output folder every couple of seconds until I retrigger the lambda function.

I've pinpointed the problem to be the upload_file function. I've tried adding the Config arg (use_threads = True).

try:

  document.save('/tmp/'+key)
  s3.upload_file('/tmp/'+newkey, bucket,'Output/'+newkey)

except Exception as e:

  print(e)
  raise e

I've figured out my mistake. This lambda function goes in a loop because it triggers itself from the file upload into the same bucket in step 4. Using a new bucket for the output file fixed the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM