{"action":"created","issue":{"url":"https://api.github.com/repos/clach04/python-tuya/issues/43","repository_url":"https://api.github.com/repos/clach04/python-tuya","labels_url":"https://api.github.com/repos/clach04/python-tuya/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/clach04/python-tuya/issues/43/comments","events_url":"https://api.github.com/repos/clach04/python-tuya/issues/43/events","html_url":"https://github.com/clach04/python-tuya/pull/43","id":375159255,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI2NjY5ODY5","number":43,"title":"Added retry logic to improve state change success","user":{"login":"caffeinatedMike","id":22151742,"node_id":"MDQ6VXNlcjIyMTUxNzQy","avatar_url":"https://avatars1.githubusercontent.com/u/22151742?v=4","gravatar_id":"","url":"https://api.github.com/users/caffeinatedMike","html_url":"https://github.com/caffeinatedMike","followers_url":"https://api.github.com/users/caffeinatedMike/followers","following_url":"https://api.github.com/users/caffeinatedMike/following{/other_user}","gists_url":"https://api.github.com/users/caffeinatedMike/gists{/gist_id}","starred_url":"https://api.github.com/users/caffeinatedMike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caffeinatedMike/subscriptions","organizations_url":"https://api.github.com/users/caffeinatedMike/orgs","repos_url":"https://api.github.com/users/caffeinatedMike/repos","events_url":"https://api.github.com/users/caffeinatedMike/events{/privacy}","received_events_url":"https://api.github.com/users/caffeinatedMike/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-10-29T18:35:24Z","updated_at":"2018-10-29T18:39:25Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/clach04/python-tuya/pulls/43","html_url":"https://github.com/clach04/python-tuya/pull/43","diff_url":"https://github.com/clach04/python-tuya/pull/43.diff","patch_url":"https://github.com/clach04/python-tuya/pull/43.patch"},"body":"Closes #31 \r\n\r\n- Added retry logic to the minimize state_change & state_update timeouts & connection refusals\r\n\r\n:exclamation: Important :exclamation: I need others to test this change to see if it works as intended and to ensure it doesn't pose and unintended side-effects (memory leaks, etc)."},"comment":{"url":"https://api.github.com/repos/clach04/python-tuya/issues/comments/434030782","html_url":"https://github.com/clach04/python-tuya/pull/43#issuecomment-434030782","issue_url":"https://api.github.com/repos/clach04/python-tuya/issues/43","id":434030782,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNDAzMDc4Mg==","user":{"login":"left4taco","id":4816327,"node_id":"MDQ6VXNlcjQ4MTYzMjc=","avatar_url":"https://avatars3.githubusercontent.com/u/4816327?v=4","gravatar_id":"","url":"https://api.github.com/users/left4taco","html_url":"https://github.com/left4taco","followers_url":"https://api.github.com/users/left4taco/followers","following_url":"https://api.github.com/users/left4taco/following{/other_user}","gists_url":"https://api.github.com/users/left4taco/gists{/gist_id}","starred_url":"https://api.github.com/users/left4taco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/left4taco/subscriptions","organizations_url":"https://api.github.com/users/left4taco/orgs","repos_url":"https://api.github.com/users/left4taco/repos","events_url":"https://api.github.com/users/left4taco/events{/privacy}","received_events_url":"https://api.github.com/users/left4taco/received_events","type":"User","site_admin":false},"created_at":"2018-10-29T18:39:25Z","updated_at":"2018-10-29T18:39:25Z","author_association":"NONE","body":"I'll test it tonight. But the problem I see now is, you always catch the exception with continue. That means the exception might always get ignored. \r\n\r\nWill this be better?\r\n```python\r\n        for i in range(3):\r\n            try:\r\n                s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\r\n                s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)\r\n                s.settimeout(self.connection_timeout)\r\n                s.connect((self.address, self.port))\r\n                s.send(payload)\r\n                data = s.recv(1024)\r\n                s.close()\r\n                return data\r\n            except socket.error:\r\n                if i >= 3:\r\n                # raise some exception\r\n                else:\r\n                  continue\r\n```"}}
{"actor":{"display_login":"left4taco"}}