Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
changed threadpoolexecutor to use a with statement as per python docs
Browse files Browse the repository at this point in the history
  • Loading branch information
oscargws committed Dec 20, 2018
1 parent ee5fa17 commit 5016cce
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions SES/SESMailer/ses_mailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,13 @@ def lambda_handler(event, context):
raise ValueError('Cannot continue without a text or html message file.')

# Send in parallel using several threads
e = concurrent.futures.ThreadPoolExecutor(max_workers=max_threads)
for row in reader:
from_address = row['from_address'].strip()
to_address = row['to_address'].strip()
subject = row['subject'].strip()
message = mime_email(subject, from_address, to_address, mime_message_text, mime_message_html)
e.submit(send_mail, from_address, to_address, message)
e.shutdown()
with concurrent.futures.ThreadPoolExecutor(max_workers=max_threads) as e:
for row in reader:
from_address = row['from_address'].strip()
to_address = row['to_address'].strip()
subject = row['subject'].strip()
message = mime_email(subject, from_address, to_address, mime_message_text, mime_message_html)
e.submit(send_mail, from_address, to_address, message)
except Exception as e:
print(e.message + ' Aborting...')
raise e
Expand Down

0 comments on commit 5016cce

Please sign in to comment.