Cleanup pubchannel polling

zmq poller returns either zmq socket objects of raw FDs. adding an API in the clients to differentiate
This commit is contained in:
Thomas Jackson 2015-02-28 11:41:57 -08:00
parent 5731a01209
commit 11195c4f2c
5 changed files with 16 additions and 4 deletions

View File

@ -1591,7 +1591,7 @@ class Minion(MinionBase):
self._process_beacons()
# TODO: rename?? Maybe do_pub_recv and take a list of them?
# for some reason, native FDs sometimes return event 5, whatever that is...
if socks.get(self.pub_channel.socket.fileno()):
if socks.get(self.pub_channel.poll_key):
print ('got stuff from pub_channel')
self._do_socket_recv()

View File

@ -104,4 +104,11 @@ class PubChannel(object):
'''
raise NotImplementedError()
@property
def poll_key(self):
'''
Return the representation that the poller will return
'''
raise NotImplementedError()
# EOF

View File

@ -109,9 +109,6 @@ class PubServerChannel(object):
elif 'transport' in opts.get('pillar', {}).get('master', {}):
ttype = opts['pillar']['master']['transport']
# TODO: remove
ttype = 'tcp'
# switch on available ttypes
if ttype == 'zeromq':
import salt.transport.zeromq

View File

@ -94,6 +94,10 @@ class TCPPubChannel(salt.transport.client.PubChannel):
def socket(self):
return self._socket
@property
def poll_key(self):
return self._socket.fileno()
@property
def master_pub(self):
'''

View File

@ -282,6 +282,10 @@ class ZeroMQPubChannel(salt.transport.client.PubChannel):
def socket(self):
return self._socket
@property
def poll_key(self):
return self.socket
class ZeroMQReqServerChannel(salt.transport.server.ReqServerChannel):
def zmq_device(self):