def __init__(
            self, node, sock_dir=None,
            opts=None, listen=True, io_loop=None,
            keep_loop=False, raise_errors=False):
        '''
        :param IOLoop io_loop: Pass in an io_loop if you want asynchronous
                               operation for obtaining events. Eg use of
                               set_event_handler() API. Otherwise, operation
                               will be synchronous.
        :param Bool keep_loop: Pass a boolean to determine if we want to keep
                               the io loop or destroy it when the event handle
                               is destroyed. This is useful when using event
                               loops from within third party asynchronous code
        '''
        self.serial = salt.payload.Serial({'serial': 'msgpack'})
        self.keep_loop = keep_loop
        if io_loop is not None:
            self.io_loop = io_loop
            self._run_io_loop_sync = False
        else:
            self.io_loop = tornado.ioloop.IOLoop()
            self._run_io_loop_sync = True
        self.cpub = False
        self.cpush = False
        self.subscriber = None
        self.pusher = None
        self.raise_errors = raise_errors

        if opts is None:
            opts = {}
        if node == 'master':
            self.opts = salt.config.DEFAULT_MASTER_OPTS.copy()
        else:
            self.opts = salt.config.DEFAULT_MINION_OPTS.copy()
        self.opts.update(opts)

        if sock_dir is None:
            sock_dir = self.opts['sock_dir']
        else:
            self.opts['sock_dir'] = sock_dir

        if salt.utils.platform.is_windows() and 'ipc_mode' not in opts:
            self.opts['ipc_mode'] = 'tcp'
        self.puburi, self.pulluri = self.__load_uri(sock_dir, node)
        self.pending_tags = []
        self.pending_events = []
        self.__load_cache_regex()
        if listen and not self.cpub:
            # Only connect to the publisher at initialization time if
            # we know we want to listen. If we connect to the publisher
            # and don't read out events from the buffer on an on-going basis,
            # the buffer will grow resulting in big memory usage.
            self.connect_pub()
def __init__ ( self , node , sock_dir = None , opts = None , listen = True , io_loop = None , keep_loop = False , raise_errors = False ) : self . serial = salt . payload . Serial ( { 'serial' : 'msgpack' } ) self . keep_loop = keep_loop if io_loop is not None : self . io_loop = io_loop self . _run_io_loop_sync = False else : self . io_loop = tornado . ioloop . IOLoop ( ) self . _run_io_loop_sync = True self . cpub = False self . cpush = False self . subscriber = None self . pusher = None self . raise_errors = raise_errors if opts is None : opts = { } if node == 'master' : self . opts = salt . config . DEFAULT_MASTER_OPTS . copy ( ) else : self . opts = salt . config . DEFAULT_MINION_OPTS . copy ( ) self . opts . update ( opts ) if sock_dir is None : sock_dir = self . opts [ 'sock_dir' ] else : self . opts [ 'sock_dir' ] = sock_dir if salt . utils . platform . is_windows ( ) and 'ipc_mode' not in opts : self . opts [ 'ipc_mode' ] = 'tcp' self . puburi , self . pulluri = self . __load_uri ( sock_dir , node ) self . pending_tags = [ ] self . pending_events = [ ] self . __load_cache_regex ( ) if listen and not self . cpub : self . connect_pub ( )
:param IOLoop io_loop: Pass in an io_loop if you want asynchronous
                               operation for obtaining events. Eg use of
                               set_event_handler() API. Otherwise, operation
                               will be synchronous.
        :param Bool keep_loop: Pass a boolean to determine if we want to keep
                               the io loop or destroy it when the event handle
                               is destroyed. This is useful when using event
                               loops from within third party asynchronous code