{"action":"closed","issue":{"url":"https://api.github.com/repos/kizniche/Mycodo/issues/56","labels_url":"https://api.github.com/repos/kizniche/Mycodo/issues/56/labels{/name}","comments_url":"https://api.github.com/repos/kizniche/Mycodo/issues/56/comments","events_url":"https://api.github.com/repos/kizniche/Mycodo/issues/56/events","html_url":"https://github.com/kizniche/Mycodo/issues/56","id":118541521,"number":56,"title":"int and time.time() and precision ","user":{"login":"Cabalist","id":828557,"avatar_url":"https://avatars.githubusercontent.com/u/828557?v=3","gravatar_id":"","url":"https://api.github.com/users/Cabalist","html_url":"https://github.com/Cabalist","followers_url":"https://api.github.com/users/Cabalist/followers","following_url":"https://api.github.com/users/Cabalist/following{/other_user}","gists_url":"https://api.github.com/users/Cabalist/gists{/gist_id}","starred_url":"https://api.github.com/users/Cabalist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cabalist/subscriptions","organizations_url":"https://api.github.com/users/Cabalist/orgs","repos_url":"https://api.github.com/users/Cabalist/repos","events_url":"https://api.github.com/users/Cabalist/events{/privacy}","received_events_url":"https://api.github.com/users/Cabalist/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/kizniche/Mycodo/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-24T06:27:21Z","updated_at":"2015-11-25T04:18:36Z","closed_at":"2015-11-25T04:18:36Z","body":"Out of curiosity why is time cast as an ```int``` in your code?  \r\n\r\nExamples:\r\n\r\nroughly L2009 in mycodo.py\r\n```python\r\nwhile last_ht_reading > int(time.time()):\r\n        time.sleep(0.25)\r\n```\r\nor\r\n\r\nroughly L2038 in mycodo.py\r\n```python \r\nlast_ht_reading = int(time.time()) + 2\r\n```\r\n\r\ntime.time() returns a ```float``` normally and python will add and compare ```int```s and ```float```s without issue.\r\n\r\n\r\nIt produce inexact results in timers as well.  \r\n\r\nConsider ```time.time()``` is 1448345968.99.  Converted to an int that is 1448345968.  It takes one ```time.sleep(0.25)``` to become 1448345969.  \r\n\r\nNow consider  ```time.time()``` is 1448345968.01.  Again converted to an int that is 1448345968. But it takes 4 ```time.sleep(0.25)``` to become 1448345969.  \r\n\r\nYour readings from the sensors could take ± .75 seconds here.  Floats would alleviate the precision issue.  \r\n\r\nJust curious. :) \r\n\r\n"}}