{"action":"created","issue":{"url":"https://api.github.com/repos/celery/kombu/issues/680","repository_url":"https://api.github.com/repos/celery/kombu","labels_url":"https://api.github.com/repos/celery/kombu/issues/680/labels{/name}","comments_url":"https://api.github.com/repos/celery/kombu/issues/680/comments","events_url":"https://api.github.com/repos/celery/kombu/issues/680/events","html_url":"https://github.com/celery/kombu/issues/680","id":198864118,"number":680,"title":"timestamp should be moved out of if statement in TokenBucket._get_tokens()","user":{"login":"Jackyele","id":18418038,"avatar_url":"https://avatars.githubusercontent.com/u/18418038?v=3","gravatar_id":"","url":"https://api.github.com/users/Jackyele","html_url":"https://github.com/Jackyele","followers_url":"https://api.github.com/users/Jackyele/followers","following_url":"https://api.github.com/users/Jackyele/following{/other_user}","gists_url":"https://api.github.com/users/Jackyele/gists{/gist_id}","starred_url":"https://api.github.com/users/Jackyele/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jackyele/subscriptions","organizations_url":"https://api.github.com/users/Jackyele/orgs","repos_url":"https://api.github.com/users/Jackyele/repos","events_url":"https://api.github.com/users/Jackyele/events{/privacy}","received_events_url":"https://api.github.com/users/Jackyele/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-01-05T02:48:36Z","updated_at":"2017-01-18T02:45:41Z","closed_at":null,"body":"\r\n``` python\r\ndef _get_tokens(self):\r\n    if self._tokens < self.capacity:\r\n        now = monotonic()   # <----------- Line 79\r\n        delta = self.fill_rate * (now - self.timestamp)\r\n        self._tokens = min(self.capacity, self._tokens + delta)\r\n        self.timestamp = now   # <--------- Line 82\r\n    return self._tokens\r\n```\r\n\r\nLine 79 and 82 should be moved outside of if statement, as [link](http://code.activestate.com/recipes/511490-implementation-of-the-token-bucket-algorithm/?in=lang-python#c2) shown\r\n\r\n``` python\r\ndef _get_tokens(self):\r\n    now = monotonic()    # <--------\r\n    if self._tokens < self.capacity:\r\n        delta = self.fill_rate * (now - self.timestamp)\r\n        self._tokens = min(self.capacity, self._tokens + delta)\r\n    self.timestamp = now  # <----------\r\n    return self._tokens\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/celery/kombu/issues/comments/273367588","html_url":"https://github.com/celery/kombu/issues/680#issuecomment-273367588","issue_url":"https://api.github.com/repos/celery/kombu/issues/680","id":273367588,"user":{"login":"jackyfkc","id":8088318,"avatar_url":"https://avatars.githubusercontent.com/u/8088318?v=3","gravatar_id":"","url":"https://api.github.com/users/jackyfkc","html_url":"https://github.com/jackyfkc","followers_url":"https://api.github.com/users/jackyfkc/followers","following_url":"https://api.github.com/users/jackyfkc/following{/other_user}","gists_url":"https://api.github.com/users/jackyfkc/gists{/gist_id}","starred_url":"https://api.github.com/users/jackyfkc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jackyfkc/subscriptions","organizations_url":"https://api.github.com/users/jackyfkc/orgs","repos_url":"https://api.github.com/users/jackyfkc/repos","events_url":"https://api.github.com/users/jackyfkc/events{/privacy}","received_events_url":"https://api.github.com/users/jackyfkc/received_events","type":"User","site_admin":false},"created_at":"2017-01-18T02:45:41Z","updated_at":"2017-01-18T02:45:41Z","body":"+1"}}
{"actor":{"display_login":"jackyfkc"}}