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

Allow to define request timeout #14

Open
Programie opened this issue Oct 20, 2017 · 4 comments
Open

Allow to define request timeout #14

Programie opened this issue Oct 20, 2017 · 4 comments

Comments

@Programie
Copy link

Currently this library doesn't seem to support setting a request timeout. In case the Unifi Controller is not responding, a script using this library is waiting infinitely.

In my case I'm using this library in a small local check for Check_MK to monitor my access points. If the Unifi Controller is not responding, every check will start an additional Python process waiting for the Unifi Controller to respond which will soon end in having hundreds of processes waiting for the Unifi Controller.

Could you please add the possibility to specify the timeout for the API requests?

@finish06
Copy link
Owner

Great idea. I think this can be accomplished with the requests module. I will start playing with this...

Thanks!

@Programie
Copy link
Author

I don't have much knowledge in Python, but maybe this will help: http://docs.python-requests.org/en/master/user/quickstart/#timeouts

@vsnine
Copy link

vsnine commented Nov 12, 2017

I'd also like to add that if the module can't reach the UniFi Controller, in the case of the integration with Home Assistant, it causes the entire app to block, and without any noticeable error message. Took a while to find it.

Should be as simple as adding a "timeout=x" entry to each of the calls to requests. I've got a locally edited version of controller.py, i'll see about getting a pull request over to you.

@vsnine
Copy link

vsnine commented Nov 12, 2017

This is the pull request I came up with: #15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants