diff options
| author | David Pursehouse <david.pursehouse@sonymobile.com> | 2013-09-10 17:50:38 +0900 |
|---|---|---|
| committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2013-09-10 17:51:28 +0900 |
| commit | 2270e25c800b3e7cd205df267698658efd417257 (patch) | |
| tree | 928315cc1f96cf8a664c433b1d053333499455b4 /pygerrit | |
| parent | 0545fac002ed2172957afa0017b872b6630f4ca0 (diff) | |
| download | pygerrit-2270e25c800b3e7cd205df267698658efd417257.tar.gz | |
Fix #1: Use select.select() instead of select.poll()
select.poll() does not work on all platforms.
Replace it with select.select().
Change-Id: Iadd09127c99b5b47ebc28f6f4e57fcc1eb4c8710
Diffstat (limited to 'pygerrit')
| -rw-r--r-- | pygerrit/stream.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/pygerrit/stream.py b/pygerrit/stream.py index d7633e8..a9f94ae 100644 --- a/pygerrit/stream.py +++ b/pygerrit/stream.py @@ -28,7 +28,7 @@ Class to listen to the Gerrit event stream and dispatch events. import json import logging -from select import poll, POLLIN +from select import select from threading import Thread, Event from .error import GerritError @@ -73,18 +73,16 @@ class GerritStream(Thread): except GerritError as e: self._error_event(e) else: - poller = poll() stdout = result.stdout - poller.register(stdout.channel) + inputready, _outputready, _exceptready = \ + select([stdout.channel], [], []) while not self._stop.is_set(): - data = poller.poll() - for (handle, event) in data: - if handle == stdout.channel.fileno() and event == POLLIN: - try: - line = stdout.readline() - json_data = json.loads(line) - self._gerrit.put_event(json_data) - except (ValueError, IOError) as err: - self._error_event(err) - except GerritError as err: - logging.error("Failed to put event: %s", err) + for _event in inputready: + try: + line = stdout.readline() + json_data = json.loads(line) + self._gerrit.put_event(json_data) + except (ValueError, IOError) as err: + self._error_event(err) + except GerritError as err: + logging.error("Failed to put event: %s", err) |
