{"action":"created","issue":{"url":"https://api.github.com/repos/pyudev/pyudev/issues/194","repository_url":"https://api.github.com/repos/pyudev/pyudev","labels_url":"https://api.github.com/repos/pyudev/pyudev/issues/194/labels{/name}","comments_url":"https://api.github.com/repos/pyudev/pyudev/issues/194/comments","events_url":"https://api.github.com/repos/pyudev/pyudev/issues/194/events","html_url":"https://github.com/pyudev/pyudev/issues/194","id":164586830,"number":194,"title":"Stack trace from MonitorObserver thread","user":{"login":"penguinland","id":2861124,"avatar_url":"https://avatars.githubusercontent.com/u/2861124?v=3","gravatar_id":"","url":"https://api.github.com/users/penguinland","html_url":"https://github.com/penguinland","followers_url":"https://api.github.com/users/penguinland/followers","following_url":"https://api.github.com/users/penguinland/following{/other_user}","gists_url":"https://api.github.com/users/penguinland/gists{/gist_id}","starred_url":"https://api.github.com/users/penguinland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/penguinland/subscriptions","organizations_url":"https://api.github.com/users/penguinland/orgs","repos_url":"https://api.github.com/users/penguinland/repos","events_url":"https://api.github.com/users/penguinland/events{/privacy}","received_events_url":"https://api.github.com/users/penguinland/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pyudev/pyudev/labels/bug","name":"bug","color":"ff0000"},{"url":"https://api.github.com/repos/pyudev/pyudev/labels/challenging","name":"challenging","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2016-07-08T18:17:10Z","updated_at":"2016-07-25T14:58:51Z","closed_at":null,"body":"I'm using pyudev version 0.20 in a Python3 process. Sometimes, everything works fine, but sometimes the `MonitorObserver` thread crashes with this stack trace:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python3.4/threading.py\", line 920, in _bootstrap_inner\r\n    self.run()\r\n  File \"/usr/local/lib/python3.4/dist-packages/pyudev/monitor.py\", line 530, in run\r\n    for device in iter(read_device, None):\r\n  File \"/usr/local/lib/python3.4/dist-packages/pyudev/_util.py\", line 167, in eintr_retry_call\r\n    return func(*args, **kwargs)\r\n  File \"/usr/local/lib/python3.4/dist-packages/pyudev/monitor.py\", line 357, in poll\r\n    if eintr_retry_call(Poll.for_events((self, 'r')).poll, timeout):\r\n  File \"/usr/local/lib/python3.4/dist-packages/pyudev/_util.py\", line 167, in eintr_retry_call\r\n    return func(*args, **kwargs)\r\n  File \"/usr/local/lib/python3.4/dist-packages/pyudev/os.py\", line 213, in poll\r\n    return list(self._parse_events(eintr_retry_call(self._notifier.poll, timeout)))\r\n  File \"/usr/local/lib/python3.4/dist-packages/pyudev/os.py\", line 228, in _parse_events\r\n    raise IOError('Error while polling fd: {0!r}'.format(fd))\r\nOSError: Error while polling fd: 8\r\n```\r\n\r\nI've tried looking into this, and found that file descriptor 8 is the udev `Monitor` object itself, and its associated `event_mask` is 9 (which is `select.POLLIN | select.POLLERR`). If I modify the `_parse_events` function to just log a warning and then skip the file instead of raising an `IOError`, I get that same \"file\" over and over, and no longer receive updates about which devices are connected and disconnected.\r\n\r\nWhat can I do differently to avoid this crash (or to continue getting updates when devices are connected/disconnected despite this crash)? Thanks in advance for the help.\r\n\r\nNot sure if relevant: I've got a custom circuit board with a whole bunch of USB switches on it, and I'm using pyudev to do things when these switches turn on and off. When this board is reset, it's common to have a couple dozen USB devices all connect or disconnect in unison, and I think that's when these stack traces happen."},"comment":{"url":"https://api.github.com/repos/pyudev/pyudev/issues/comments/234978692","html_url":"https://github.com/pyudev/pyudev/issues/194#issuecomment-234978692","issue_url":"https://api.github.com/repos/pyudev/pyudev/issues/194","id":234978692,"user":{"login":"mulkieran","id":1218366,"avatar_url":"https://avatars.githubusercontent.com/u/1218366?v=3","gravatar_id":"","url":"https://api.github.com/users/mulkieran","html_url":"https://github.com/mulkieran","followers_url":"https://api.github.com/users/mulkieran/followers","following_url":"https://api.github.com/users/mulkieran/following{/other_user}","gists_url":"https://api.github.com/users/mulkieran/gists{/gist_id}","starred_url":"https://api.github.com/users/mulkieran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulkieran/subscriptions","organizations_url":"https://api.github.com/users/mulkieran/orgs","repos_url":"https://api.github.com/users/mulkieran/repos","events_url":"https://api.github.com/users/mulkieran/events{/privacy}","received_events_url":"https://api.github.com/users/mulkieran/received_events","type":"User","site_admin":false},"created_at":"2016-07-25T14:58:51Z","updated_at":"2016-07-25T14:58:51Z","body":"The MonitorObserver is set up in a way that allows the Monitor to be shared among multiple MonitorObservers. This means, that if the MonitorObserver manages the Monitor by making a new one, and there are multiple observers, the eventual outcome could be surprising.\r\n\r\nI'm thinking of adding a new class, MonitorMaster, that keeps its Monitor object internal (and thus can manage it w/out worrying about other observers). What do you think?\r\n\r\n\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"mulkieran"}}