Skip to content

Commit 7849c57

Browse files
loops add calls, issue 64
resolve apel#64. loops the add calls until they work or until the for loop is exhausted. is something like this what you mean?
1 parent a70754c commit 7849c57

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

ssm/ssm2.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def _handle_msg(self, text):
316316

317317
return message, signer, None
318318

319-
fails = 0
319+
320320
def _save_msg_to_queue(self, body, empaid):
321321
"""Extract message contents and add to the accept or reject queue."""
322322
extracted_msg, signer, err_msg = self._handle_msg(body)
@@ -350,9 +350,18 @@ def _save_msg_to_queue(self, body, empaid):
350350

351351
except (IOError, OSError) as error:
352352
log.error('Failed to read or write file: %s', error)
353-
fails += 1
354-
if fails <= 3:
355-
return _save_msg_to_queue(self, body, empaid)
353+
for i in range(3):
354+
try:
355+
name = self._rejectq.add({'body': body,
356+
'signer': signer,
357+
'empaid': empaid,
358+
'error': err_msg})
359+
name = self._inq.add({'body': extracted_msg,
360+
'signer': signer,
361+
'empaid': empaid})
362+
except:
363+
continue
364+
break
356365

357366
def _send_msg(self, message, msgid):
358367
"""Send one message using stomppy.

0 commit comments

Comments
 (0)