JurajNyiri / pytapo

Python library for communication with Tapo Cameras
MIT License
277 stars 58 forks source link

No timeout in requests calls #99

Closed eric2gif closed 2 months ago

eric2gif commented 7 months ago

I have built a script that implements an MQTT client based on the pytapo (getEvents) method. The script keeps on interrogating my camera in search of a new event but also manages the MQTT keepalive with the broker. So it is essential that the getEvents interrogation is not locking the entire processing. Unfortunately, I found that my camera has very unsteady response times (most of the time response in a few seconds but sometimes response time is greater than 30 seconds). The greatest response times cause my MQTT connection to break. I have dig in the pytapo code and noticed that it makes calls to the "requests" package and that most of the requests class methods are able to handle a "timeout" parameter. BTW, I totally agree with what is written in the requests documentation "Most requests to external servers should have a timeout attached, in case the server is not responding in a timely manner.". I have tested a quick and dirty patch in the pytapo code: Pytapo_patch_timeout Is it possible to have a clean implementation of the requests timeout in the pytapo package?

JurajNyiri commented 2 months ago

Not going to implement. Some cameras are slow and it is ok to wait for the response to come.