-
Notifications
You must be signed in to change notification settings - Fork 36
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
xmlrpc: don't re-raise the exception when retry fails #258
Conversation
Test output:
|
kobo/xmlrpc.py
Outdated
@@ -481,7 +481,8 @@ def request(self, *args, **kwargs): | |||
except (socket.error, socket.herror, socket.gaierror, socket.timeout, | |||
httplib.CannotSendRequest, xmlrpclib.ProtocolError) as ex: | |||
if i >= self.retry_count: | |||
raise | |||
print(f"XML-RPC connection to {args[0]} failed: {ex}", file=sys.stderr) | |||
sys.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not expect retry_request_decorator()
to terminate the process when a connection fails. That feels totally wrong. If such behavior is desired, the re-raised exception needs to be caught again at a higher level and handled as needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exceptions occur when initializing a hub proxy. I'm doubting whether it's worth a fix at all since it needs to quit somewhere even at a higher level.
I reverted this and moved the exception handling upper.
05bd550
to
65ae586
Compare
The Please take a look. |
@rhyw Using
|
Do you have a better idea which is a better/higher place? I think it happens during hub proxy inialization and after the retries failed.
This is try to handle the exception when hub is unreachable due to various connection issues. See issue description in https://issues.redhat.com/browse/OSH-144 |
@rhyw Please show me the traceback and I will tell you where I think the exception could be caught. I cannot see any traceback in the description of https://issues.redhat.com/browse/OSH-144 though. |
See for example deprecated issue 100:
|
@rhyw I think the place where For example What about the following approach?
The disadvantage is that it will break applications that are catching |
Either way, there should be somewhere to exit the process. Raising exceptions expose the tracebacks to cli, which should be fixed if possible. I don't see how
yeah it may have various exceptions, it's better to preserve original exception type/message such that we have more clues of the error. I'd rather do nothing in kobo(keep it as it is) and catch exceptions in OSH cli directly. WDYT? |
Calling
That is exactly what I had in mind while creating OSH-144. The downside is that when you catch |
I don't have a strong sense of distinguish the cases. I was attempting to handle exception where it was originall raised. Catch in osh cli would be much simpler although it could be too generic. I'll close this MR and upload an MR in openscanhub repo instead. Thanks for the suggestions! |
closing in favor of openscanhub/openscanhub#250 |
Related: https://issues.redhat.com/browse/OSH-144