Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repeated _save_msg_to_queue procedure until message can be saved. issue 64 #249

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from
21 changes: 20 additions & 1 deletion ssm/ssm2.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,11 @@ def _handle_msg(self, text):

return message, signer, None


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)

try:
# If the message is empty or the error message is not empty
# then reject the message.
Expand All @@ -343,10 +345,27 @@ def _save_msg_to_queue(self, body, empaid):
name = self._inq.add({'body': extracted_msg,
'signer': signer,
'empaid': empaid})
log.info("Message saved to incoming queue as %s", name)

log.info("Message saved to incoming queue as %s", name)
DanielPerkins7 marked this conversation as resolved.
Show resolved Hide resolved

except (IOError, OSError) as error:
log.error('Failed to read or write file: %s', error)
for i in range(3):
try:
if extracted_msg is None or err_msg is not None:
name = self._rejectq.add({'body': body,
'signer': signer,
'empaid': empaid,
'error': err_msg})
log.info("Message saved to reject queue as %s", name)
else: # message verified ok
name = self._inq.add({'body': extracted_msg,
'signer': signer,
'empaid': empaid})
log.info("Message saved to incoming queue as %s", name)
except:

Check notice

Code scanning / CodeQL

Except block handles 'BaseException'

Except block directly handles BaseException.
continue
break

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