aruba / pyaoscx

Python modules for AOS-CX
Apache License 2.0
37 stars 25 forks source link

API call functions don't have timeouts #26

Open cs-1 opened 1 year ago

cs-1 commented 1 year ago

...

EDIT: I located the problem, see next post.

cs-1 commented 1 year ago

The problem seems to occur in all functions that do API calls to the switch. I have located the problem in

https://github.com/aruba/pyaoscx/blob/aa91f087304859124f8a2fd91b7cbe1981c306a0/pyaoscx/session.py#L356-L362

There's no connection or read timeout set here. Changing this to

        return operations[operation](
            self._build_uri(path),
            verify=verify,
            params=params,
            data=data,
            proxies=self.proxy,
            timeout=(5,30)
        )

seems to fix the problem (the timeout is set to 5, the read timeout to 30 seconds).

federstedt commented 12 months ago

Can you change this so it can be changed from an ansible variable in playbook maybe ? I've hade issues with timeouts when set to 5 sec on some jobs.

cs-1 commented 12 months ago

We do not use pyaoscx within Ansible, we're using it in our own python tools. 5s was just a suggestion. This could be set to any other reasonable value as long as there is a timeout at all. You could implement this to have a default timeout which can be overridden by software that uses pyaoscx like Ansible.