lucasheld / uptime-kuma-api

A Python wrapper for the Uptime Kuma Socket.IO API
https://uptime-kuma-api.readthedocs.io
MIT License
272 stars 21 forks source link

Add global timeouts #33

Closed lucasheld closed 1 year ago

lucasheld commented 1 year ago

In some cases, certain events never arrive. This can happen, for example, if you call the cert_info method without having a monitor that uses TLS. It is difficult to address all these special cases individually. Especially without documentation when this happens. Instead, timeouts for all methods would be useful, also for other errors. In order not to block the application forever.

simonmicro commented 1 year ago

This is a very good point - I was just here to create a PR for that (but as you are on that issue too, I won't for now)! A very simple solution would be to set the timeout parameter of https://github.com/lucasheld/uptime-kuma-api/blob/a576ed9f3a96c6e4d240a352c210c4c78ac48c7f/uptime_kuma_api/api.py#L484 ! Because the timeouts of ~60 seconds are horrible for fast api interactions...

For myself I already drastically sped up the error handling with...

r = self.sio.call(event, data, timeout=self.wait_timeout)

...which also forced me to implement retry-mechanisms in my own code (which is a good practice anyway).

lucasheld commented 1 year ago

@simonmicro I have created a pull request: #34. What do you think?

lucasheld commented 1 year ago

It's included in release 1.0.1