diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2014-06-24 15:55:35 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2014-06-24 15:55:35 (GMT) |
commit | 8d2b8d71f98d7d13c13fb4c7b1fd1d058f0cf4d4 (patch) | |
tree | a3e1185165755a95747b88d536006de300caf000 | |
parent | 8f6e599c5f886f21394d4c8543c30952df56501f (diff) |
Don't use a thread demon on sensors.py
Also close the file
All this is to try avoid a crash
-rw-r--r-- | sensors.py | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -50,16 +50,14 @@ class EbookModeDetector(GObject.GObject): def _start_reading(self): thread = threading.Thread(target=self._read) - thread.daemon = True thread.start() def _read(self): fd = open(self.EBOOK_DEVICE, 'rb') for x in range(12): fd.read(1) - self._report_change(ord(fd.read(1))) - - def _report_change(self, value): + value = ord(fd.read(1)) + fd.close() self._ebook_mode = (value == 1) self.emit('changed', self._ebook_mode) # restart |