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
8 changes: 7 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

fails = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declaring fails here puts it outside the scope of the method, which has lead to the Travis CI failing the unit tests.

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)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Careful with adding extra whitespace.

try:
# If the message is empty or the error message is not empty
# then reject the message.
Expand All @@ -343,10 +345,14 @@ 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)
fails += 1
if fails <= 3:
return _save_msg_to_queue(self, body, empaid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that using recursion here is the right answer. A simple loop for the add calls would be the more straightforward solution.


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