supersaiyanmode / PyWebOSTV

Python API for controlling LG TVs (Web OS)
MIT License
271 stars 50 forks source link

Can there be a timeout attribute on the Connect method? #105

Open fidesachates opened 7 months ago

fidesachates commented 7 months ago

Basically the title. I have a python web app and would like to limit my request times by limiting how long the client tries to connect to the tv.

Thank you for your work on this library!

supersaiyanmode commented 7 months ago

From looking at ws4py's source, it should be fairly straightforward:

[UNTESTED CODE]


client = WebOSClient.discover()[0] # Use discover(secure=True) for newer models.
client.sock.settimeout(5)  # 5 seconds timeout.
client.connect()

Can you please verify if this works? If so, I'll add an option to the connect method to support timeout.