🐛 (api.py): Raise correct error when timeout #45
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: DGNum/uptime-kuma-api#45
Loading…
Reference in a new issue
No description provided.
Delete branch "Zerka30/return-timeout"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Related to : https://github.com/lucasheld/uptime-kuma-api/issues/44
I'll let you try it for yourself, and let me know if this function has any dependencies elsewhere.
I think that is not quite correct.
The Uptime Kuma errors are in r.get("msg"). Now they are no longer intercepted, because an Expection is not thrown in this case.
I would do it like this:
Hum 🤔 , wdym exactly?
Because the way I've done it, it will return the correct error if socket.io returns a
TimeoutError
, and for any other type of error it will return anUptimeKumaException
with the error message contained inr.get("msg")
@lucasheld , I ping you, to correct if necessary
r
is not defined whenself.sio.call
fails.@ -503,1 +503,3 @@
r = self.sio.call(event, data, timeout=self.timeout)
try:
r = self.sio.call(event, data, timeout=self.timeout)
except socketio.exceptions.TimeoutError:
The response of
self.sio.call
is not always a dict (for exampleapi.need_setup
). In this caser.pop("ok")
fails. You have deleted the code that checks if the response type is a dict.Also you have deleted the code that checks the
r["ok"]
value. The UptimeKumaException is now no longer raised when Uptime Kuma responds with an error message (whenr["ok"]
is false).I have tested this code. It works as expected.
The only problem I noticed is that there are still exceptions directly from socketio (for example
socketio.exceptions.ConnectionError
).Then these Excepetions should either be caught too or we have to use separate timeout exceptions, one for the logic within uptime-kuma-api and one for socketio timeouts. Currently, I prefer the latter.
Alright, I understand and now its fix ! :D
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.