{"action":"opened","issue":{"url":"https://api.github.com/repos/home-assistant/home-assistant/issues/5582","repository_url":"https://api.github.com/repos/home-assistant/home-assistant","labels_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/5582/labels{/name}","comments_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/5582/comments","events_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/5582/events","html_url":"https://github.com/home-assistant/home-assistant/issues/5582","id":203580345,"number":5582,"title":"system monitor process no longer exists","user":{"login":"Tommatheussen","id":13683094,"avatar_url":"https://avatars.githubusercontent.com/u/13683094?v=3","gravatar_id":"","url":"https://api.github.com/users/Tommatheussen","html_url":"https://github.com/Tommatheussen","followers_url":"https://api.github.com/users/Tommatheussen/followers","following_url":"https://api.github.com/users/Tommatheussen/following{/other_user}","gists_url":"https://api.github.com/users/Tommatheussen/gists{/gist_id}","starred_url":"https://api.github.com/users/Tommatheussen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tommatheussen/subscriptions","organizations_url":"https://api.github.com/users/Tommatheussen/orgs","repos_url":"https://api.github.com/users/Tommatheussen/repos","events_url":"https://api.github.com/users/Tommatheussen/events{/privacy}","received_events_url":"https://api.github.com/users/Tommatheussen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-01-27T08:29:58Z","updated_at":"2017-01-27T08:29:58Z","closed_at":null,"body":"**Home Assistant release (`hass --version`):**\r\n0.36.1\r\n\r\n**Python release (`python3 --version`):**\r\n3.4.3\r\n\r\n**Component/platform:**\r\n```\r\nsensor:\r\n  - platform: systemmonitor\r\n```\r\n\r\n**Description of problem:**\r\nWhen tracking the state of some processes, psutil reads in all processes and then filters them.\r\nThis results in processes sometimes being stopped before their process files have been read, resulting in an error (see traceback below).\r\n\r\n**Expected:**\r\nIt's ok that some processes have been stopped while updating, handling the error would be nicer though.\r\n\r\n**Problem-relevant `configuration.yaml` entries and steps to reproduce:**\r\n```yaml\r\nsensor:\r\n  - platform: systemmonitor\r\n     resources:\r\n       - type: process\r\n          arg: deluged\r\n       - type: process\r\n          arg: deluge-web\r\n```\r\n\r\n**Traceback (if applicable):**\r\n```bash\r\n17-01-27 01:34:54 homeassistant.core: Error doing job: Task exception was never retrieved\r\nTraceback (most recent call last):\r\n  File \"/PlexMediaServer/hass/lib/python3.4/site-packages/psutil/_pslinux.py\", line 1084, in wrapper\r\n    return fun(self, *args, **kwargs)\r\n  File \"/PlexMediaServer/hass/lib/python3.4/site-packages/psutil/_pslinux.py\", line 1157, in name\r\n    name = self._parse_stat_file()[0]\r\n  File \"/PlexMediaServer/hass/lib/python3.4/site-packages/psutil/_common.py\", line 293, in wrapper\r\n    return fun(self)\r\n  File \"/PlexMediaServer/hass/lib/python3.4/site-packages/psutil/_pslinux.py\", line 1119, in _parse_stat_file\r\n    with open_binary(\"%s/%s/stat\" % (self._procfs_path, self.pid)) as f:\r\n  File \"/PlexMediaServer/hass/lib/python3.4/site-packages/psutil/_pslinux.py\", line 181, in open_binary\r\n    return open(fname, \"rb\", **kwargs)\r\nFileNotFoundError: [Errno 2] No such file or directory: '/proc/14214/stat'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python3.4/asyncio/tasks.py\", line 234, in _step\r\n    result = coro.throw(exc)\r\n  File \"/PlexMediaServer/hass/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py\", line 387, in _update_entity_states\r\n    yield from update_coro\r\n  File \"/PlexMediaServer/hass/lib/python3.4/site-packages/homeassistant/helpers/entity.py\", line 216, in async_update_ha_state\r\n    yield from self.hass.loop.run_in_executor(None, self.update)\r\n  File \"/usr/lib/python3.4/asyncio/futures.py\", line 386, in __iter__\r\n    yield self  # This tells Task to wait for completion.\r\n  File \"/usr/lib/python3.4/asyncio/tasks.py\", line 287, in _wakeup\r\n    value = future.result()\r\n  File \"/usr/lib/python3.4/asyncio/futures.py\", line 275, in result\r\n    raise self._exception\r\n  File \"/usr/lib/python3.4/concurrent/futures/thread.py\", line 54, in run\r\n    result = self.fn(*self.args, **self.kwargs)\r\n  File \"/PlexMediaServer/hass/lib/python3.4/site-packages/homeassistant/components/sensor/systemmonitor.py\", line 137, in update\r\n    if any(self.argument in l.name() for l in psutil.process_iter()):\r\n  File \"/PlexMediaServer/hass/lib/python3.4/site-packages/homeassistant/components/sensor/systemmonitor.py\", line 137, in <genexpr>\r\n    if any(self.argument in l.name() for l in psutil.process_iter()):\r\n  File \"/PlexMediaServer/hass/lib/python3.4/site-packages/psutil/__init__.py\", line 634, in name\r\n    name = self._proc.name()\r\n  File \"/PlexMediaServer/hass/lib/python3.4/site-packages/psutil/_pslinux.py\", line 1090, in wrapper\r\n    raise NoSuchProcess(self.pid, self._name)\r\npsutil.NoSuchProcess: psutil.NoSuchProcess process no longer exists (pid=14214)\r\n```\r\n\r\n**Additional info:**\r\nI'm not sure if it's helpful, but I use it to track 4 different processes, perhaps this causes the filtering to be slow."}}
{"actor":{"display_login":"Tommatheussen"}}