Don't unsubscribe, there is no need to and it leaves zeromq

in the wrong state for a few moments and breaks the client
This commit is contained in:
Thomas S Hatch 2013-01-16 17:35:46 -07:00
parent 62d69de30e
commit 923130d827
2 changed files with 15 additions and 22 deletions

View File

@ -207,10 +207,7 @@ class LocalClient(object):
timeout=self._get_timeout(timeout),
**kwargs)
try:
return self._check_pub_data(pub_data)
finally:
self.event.unsubscribe(jid)
return self._check_pub_data(pub_data)
def cmd_async(
self,

View File

@ -147,24 +147,20 @@ class SaltEvent(object):
wait = wait * 1000
self.subscribe(tag)
try:
while True:
socks = dict(self.poller.poll(wait))
if self.sub in socks and socks[self.sub] == zmq.POLLIN:
raw = self.sub.recv()
# Double check the tag
if tag != raw[:20].rstrip('|'):
continue
data = self.serial.loads(raw[20:])
if full:
ret = {'data': data,
'tag': raw[:20].rstrip('|')}
return ret
return data
return None
finally:
# No sense in keeping subscribed to this event
self.unsubscribe(tag)
while True:
socks = dict(self.poller.poll(wait))
if self.sub in socks and socks[self.sub] == zmq.POLLIN:
raw = self.sub.recv()
# Double check the tag
if tag != raw[:20].rstrip('|'):
continue
data = self.serial.loads(raw[20:])
if full:
ret = {'data': data,
'tag': raw[:20].rstrip('|')}
return ret
return data
return None
def iter_events(self, tag='', full=False):
'''