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

Conversation

DanielPerkins7
Copy link
Contributor

resolve #64. i was unsure which part needed to be repeated so i just repeated the whole function until the message can be saved into the queue, im not sure if this is right though.

resolve apel#64.   i was unsure which part needed to be repeated so i just repeated the whole function until the message can be saved into the queue, im not sure if this is right though.
@DanielPerkins7 DanielPerkins7 requested a review from a team as a code owner August 1, 2023 14:17
ssm/ssm2.py Fixed Show fixed Hide fixed
@tofu-rocketry tofu-rocketry self-assigned this Aug 1, 2023
@tofu-rocketry
Copy link
Member

From dev meeting:

  • It's the add methods that are potentially failing, which then ends up in the except (IOError, OSError) error handling.
  • Retrying add up to 3 times would be good.

DanielPerkins7 and others added 7 commits August 2, 2023 08:11
resolve apel#64. i have just repeated the procedure either until it works or until a new counter i introduced reaches 3 so there is a limit to the recursion
procedure repeates either until it works or until the counter reaches three to avoid infinite recursion
resolve apel#64  .  repeats the procedure either until it works or until it has been repeated three times
resolve apel#64  .  repeats the procedure either until it works or until it has been repeated three times
ssm/ssm2.py Outdated
@@ -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.

ssm/ssm2.py Outdated

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.

ssm/ssm2.py Outdated
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.

resolve apel#64. loops the add calls until they work or until the for loop is exhausted. is something like this what you mean?
ssm/ssm2.py Fixed Show fixed Hide fixed
name = self._inq.add({'body': extracted_msg,
'signer': signer,
'empaid': empaid})
except:

Check notice

Code scanning / CodeQL

Except block handles 'BaseException'

Except block directly handles BaseException.
ssm/ssm2.py Outdated Show resolved Hide resolved
@tofu-rocketry tofu-rocketry added this to the 3.5.0 milestone Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Dirq sometimes failing to write temporary messages
3 participants