diff options
| -rw-r--r-- | pygerrit/client.py | 5 | ||||
| -rw-r--r-- | pygerrit/stream.py | 9 |
2 files changed, 7 insertions, 7 deletions
diff --git a/pygerrit/client.py b/pygerrit/client.py index 1d5fa44..b501b92 100644 --- a/pygerrit/client.py +++ b/pygerrit/client.py @@ -28,6 +28,7 @@ from Queue import Queue, Empty, Full from pygerrit.error import GerritError from pygerrit.events import GerritEventFactory +from pygerrit.ssh import GerritSSHClient from pygerrit.stream import GerritStream @@ -37,14 +38,14 @@ class GerritClient(object): def __init__(self, host): self._factory = GerritEventFactory() - self._host = host self._events = Queue() self._stream = None + self._ssh_client = GerritSSHClient(host) def start_event_stream(self): """ Start streaming events from `gerrit stream-events`. """ if not self._stream: - self._stream = GerritStream(self, host=self._host) + self._stream = GerritStream(self, ssh_client=self._ssh_client) self._stream.start() def stop_event_stream(self): diff --git a/pygerrit/stream.py b/pygerrit/stream.py index d324422..f9ad55e 100644 --- a/pygerrit/stream.py +++ b/pygerrit/stream.py @@ -30,7 +30,6 @@ import json from select import poll, POLLIN from threading import Thread, Event -from pygerrit.ssh import GerritSSHClient from pygerrit.error import GerritError from pygerrit.events import GerritEvent, GerritEventFactory @@ -49,11 +48,11 @@ class GerritStream(Thread): """ Gerrit events stream handler. """ - def __init__(self, gerrit, host): + def __init__(self, gerrit, ssh_client): Thread.__init__(self) self.daemon = True self._gerrit = gerrit - self._host = host + self._ssh_client = ssh_client self._stop = Event() def stop(self): @@ -63,8 +62,8 @@ class GerritStream(Thread): def run(self): """ Listen to the stream and send events to the client. """ try: - client = GerritSSHClient(self._host) - _stdin, stdout, _stderr = client.run_gerrit_command("stream-events") + _stdin, stdout, _stderr = \ + self._ssh_client.run_gerrit_command("stream-events") p = poll() p.register(stdout.channel) while not self._stop.is_set(): |
