Skip to content

Commit

Permalink
defining how many time to retry before failing
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajagarwal committed Dec 17, 2021
1 parent a083ce9 commit 3d83a30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion flask_mandrill.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def send_email(self, **kwargs):
'No from email was specified and no default was configured')

email_sent = False
attemptedsend = 0
while not email_sent:
try:
response = requests.post(endpoint,
Expand All @@ -66,7 +67,12 @@ def send_email(self, **kwargs):
except Exception as e:
print('Error sending email with template ' + data['template_name'] )
print(e)
time.sleep(30)
time.sleep(15)
if attemptedsend >= 4 :
email_sent = True
print('Failed to send email with template ' + data['template_name'] )
break
attemptedsend+=1

response.raise_for_status()
return response
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

setup(
name='Flask-Mandrill',
version='0.3',
version='0.3.1',
url='http://github.com/volker48/flask-mandrill',
license='MIT',
author='Marcus McCurdy',
Expand Down

0 comments on commit 3d83a30

Please sign in to comment.