{"action":"created","issue":{"url":"https://api.github.com/repos/kontron/python-ipmi/issues/25","repository_url":"https://api.github.com/repos/kontron/python-ipmi","labels_url":"https://api.github.com/repos/kontron/python-ipmi/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/kontron/python-ipmi/issues/25/comments","events_url":"https://api.github.com/repos/kontron/python-ipmi/issues/25/events","html_url":"https://github.com/kontron/python-ipmi/issues/25","id":332347972,"node_id":"MDU6SXNzdWUzMzIzNDc5NzI=","number":25,"title":"send_message method can loop forever","user":{"login":"BenEstrabaud","id":10847055,"node_id":"MDQ6VXNlcjEwODQ3MDU1","avatar_url":"https://avatars1.githubusercontent.com/u/10847055?v=4","gravatar_id":"","url":"https://api.github.com/users/BenEstrabaud","html_url":"https://github.com/BenEstrabaud","followers_url":"https://api.github.com/users/BenEstrabaud/followers","following_url":"https://api.github.com/users/BenEstrabaud/following{/other_user}","gists_url":"https://api.github.com/users/BenEstrabaud/gists{/gist_id}","starred_url":"https://api.github.com/users/BenEstrabaud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenEstrabaud/subscriptions","organizations_url":"https://api.github.com/users/BenEstrabaud/orgs","repos_url":"https://api.github.com/users/BenEstrabaud/repos","events_url":"https://api.github.com/users/BenEstrabaud/events{/privacy}","received_events_url":"https://api.github.com/users/BenEstrabaud/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-14T10:43:16Z","updated_at":"2018-06-15T06:16:11Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nIn the following code block:\r\n   \r\n```\r\n def send_message(self, req):\r\n        req.target = self.target\r\n        req.requester = self.requester\r\n\r\n        retry = 3\r\n        while True:\r\n            retry -= 1\r\n            try:\r\n                rsp = self.interface.send_and_receive(req)\r\n                break\r\n            except CompletionCodeError as e:\r\n                if e.cc == msgs.constants.CC_NODE_BUSY:\r\n                    retry -= 1\r\n                    continue\r\n\r\n        return rsp\r\n\r\n```\r\nThe \"retry\" variable is actually never checked. Also, If we get a CompletionCodeError when trying to call self.interface.send_and_receive, we substract one to the retry again even though we've only done a single attempt (but substracted 2 to the retry). If we consistently fail to complete the command, the while loop will never exit. Finally, \"rsp\" isn't initialized and the \"continue\" statement at the end of the code block is unecessary: the next line would automatically go to the next iteration of the while loop.\r\n\r\nThis can probably be fixed with something like that (not tested):\r\n\r\n```\r\n def send_message(self, req):\r\n        req.target = self.target\r\n        req.requester = self.requester\r\n        rsp = None\r\n        retry = 3\r\n        while retry > 0:\r\n            retry -= 1\r\n            try:\r\n                rsp = self.interface.send_and_receive(req)\r\n                break\r\n            except CompletionCodeError as e:\r\n                pass\r\n        return rsp\r\n```"},"comment":{"url":"https://api.github.com/repos/kontron/python-ipmi/issues/comments/397524410","html_url":"https://github.com/kontron/python-ipmi/issues/25#issuecomment-397524410","issue_url":"https://api.github.com/repos/kontron/python-ipmi/issues/25","id":397524410,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NzUyNDQxMA==","user":{"login":"hthiery","id":6574930,"node_id":"MDQ6VXNlcjY1NzQ5MzA=","avatar_url":"https://avatars2.githubusercontent.com/u/6574930?v=4","gravatar_id":"","url":"https://api.github.com/users/hthiery","html_url":"https://github.com/hthiery","followers_url":"https://api.github.com/users/hthiery/followers","following_url":"https://api.github.com/users/hthiery/following{/other_user}","gists_url":"https://api.github.com/users/hthiery/gists{/gist_id}","starred_url":"https://api.github.com/users/hthiery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hthiery/subscriptions","organizations_url":"https://api.github.com/users/hthiery/orgs","repos_url":"https://api.github.com/users/hthiery/repos","events_url":"https://api.github.com/users/hthiery/events{/privacy}","received_events_url":"https://api.github.com/users/hthiery/received_events","type":"User","site_admin":false},"created_at":"2018-06-15T06:16:11Z","updated_at":"2018-06-15T06:16:11Z","author_association":"CONTRIBUTOR","body":"thats is right .. do you have the chance to test your changes?"}}
{"actor":{"display_login":"hthiery"}}