diff --git a/salt/client/__init__.py b/salt/client/__init__.py index 347edd9be7..978119480e 100644 --- a/salt/client/__init__.py +++ b/salt/client/__init__.py @@ -46,8 +46,9 @@ from salt.exceptions import ( # Import third party libs try: import zmq + HAS_ZMQ = True except ImportError: - pass + HAS_ZMQ = False # Try to import range from https://github.com/ytoolshed/range HAS_RANGE = False @@ -791,17 +792,24 @@ class LocalClient(object): if event is None: event = self.event while True: - try: + if HAS_ZMQ: + try: + raw = event.get_event_noblock() + if raw and raw.get('tag', '').startswith(jid): + yield raw + else: + yield None + except zmq.ZMQError as ex: + if ex.errno == errno.EAGAIN or ex.errno == errno.EINTR: + yield None + else: + raise + else: raw = event.get_event_noblock() if raw and raw.get('tag', '').startswith(jid): yield raw else: yield None - except zmq.ZMQError as ex: - if ex.errno == errno.EAGAIN or ex.errno == errno.EINTR: - yield None - else: - raise def get_iter_returns( self,