Skip to content

Commit

Permalink
loops add calls, issue 64
Browse files Browse the repository at this point in the history
resolve apel#64. loops the add calls until they work or until the for loop is exhausted. is something like this what you mean?
  • Loading branch information
DanielPerkins7 committed Aug 2, 2023
1 parent a70754c commit 7849c57
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions ssm/ssm2.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def _handle_msg(self, text):

return message, signer, None

fails = 0

def _save_msg_to_queue(self, body, empaid):
"""Extract message contents and add to the accept or reject queue."""
extracted_msg, signer, err_msg = self._handle_msg(body)
Expand Down Expand Up @@ -350,9 +350,18 @@ def _save_msg_to_queue(self, body, empaid):

except (IOError, OSError) as error:
log.error('Failed to read or write file: %s', error)
fails += 1
if fails <= 3:
return _save_msg_to_queue(self, body, empaid)
for i in range(3):
try:
name = self._rejectq.add({'body': body,
'signer': signer,
'empaid': empaid,
'error': err_msg})
name = self._inq.add({'body': extracted_msg,
'signer': signer,
'empaid': empaid})
except:
continue
break

def _send_msg(self, message, msgid):
"""Send one message using stomppy.
Expand Down

0 comments on commit 7849c57

Please sign in to comment.