Skip to content
Open
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

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