Пример #1
0
    def _adapter_connect(self):
        """
        Connect to the given host and port
        """
        # Setup our ioloop
        if self.ioloop is None:
            self.ioloop = IOLoop.instance()

        # Setup a periodic callbacks
        if self._pc is None:
            self._pc = ioloop.PeriodicCallback(self._manage_event_state,
                                               self.callback_interval,
                                               self.ioloop)

        try:
            # Connect to RabbitMQ and start polling
            BaseConnection._adapter_connect(self)
            self.start_poller()

            # Let everyone know we're connected
            self._on_connected()
        except AMQPConnectionError, e:
            # If we don't have RS just raise the exception
            if isinstance(self.reconnection, NullReconnectionStrategy):
                raise e
            # Trying to reconnect
            self.reconnection.on_connection_closed(self)
Пример #2
0
 def __init__(self,
              parameters=None,
              on_open_callback=None,
              reconnection_strategy=None):
     # Run our base connection init
     BaseConnection.__init__(self, parameters, on_open_callback,
                             reconnection_strategy)
Пример #3
0
    def _adapter_disconnect(self):
        """
        Disconnect from the RabbitMQ Broker
        """
        self.stop_poller()

        BaseConnection._adapter_disconnect(self)
Пример #4
0
 def _on_connected(self):
     # Call superclass and then update the event state to flush the outgoing
     # frame out. Commit 50d842526d9f12d32ad9f3c4910ef60b8c301f59 removed a
     # self._flush_outbound call that was in _send_frame which previously
     # made this step unnecessary.
     BaseConnection._on_connected(self)
     self._manage_event_state()
Пример #5
0
    def _adapter_connect(self):
        """
        Connect to the given host and port
        """
        # Setup our ioloop
        if self.ioloop is None:
            self.ioloop = self._default_ioloop

        # Setup a periodic callbacks
        if self._pc is None:
            self._pc = ioloop.PeriodicCallback(self._manage_event_state,
                                               self.callback_interval,
                                               self.ioloop)

        try:
            # Connect to RabbitMQ and start polling
            BaseConnection._adapter_connect(self)
            self.start_poller()

            # Let everyone know we're connected
            self._on_connected()
        except AMQPConnectionError, e:
            # If we don't have RS just raise the exception
            if isinstance(self.reconnection, NullReconnectionStrategy):
                raise e
            # Trying to reconnect
            self.reconnection.on_connection_closed(self)
Пример #6
0
 def _on_connected(self):
     # Call superclass and then update the event state to flush the outgoing
     # frame out. Commit 50d842526d9f12d32ad9f3c4910ef60b8c301f59 removed a
     # self._flush_outbound call that was in _send_frame which previously
     # made this step unnecessary.
     BaseConnection._on_connected(self)
     self._manage_event_state()
Пример #7
0
    def _adapter_disconnect(self):
        """
        Disconnect from the RabbitMQ Broker
        """
        self.stop_poller()

        BaseConnection._adapter_disconnect(self)
Пример #8
0
    def _handle_disconnect(self):
        """
        Called internally when we know our socket is disconnected already
        """
        self.stop_poller()

        BaseConnection._handle_disconnect(self)
Пример #9
0
    def _handle_disconnect(self):
        """
        Called internally when we know our socket is disconnected already
        """
        self.stop_poller()

        BaseConnection._handle_disconnect(self)
Пример #10
0
 def _adapter_connect(self):
     # Connect (blockignly!) to the server
     BaseConnection._adapter_connect(self)
     self.event_state |= WRITE
     # Setup the IOLoop
     self.ioloop = IOLoop(self.notifiers)
     # Let everyone know we're connected
     self._on_connected()
Пример #11
0
 def channel(self, channel_number=None):
     """
     Return a Deferred that fires with an instance of a wrapper aroud the
     Pika Channel class.
     """
     d = defer.Deferred()
     BaseConnection.channel(self, d.callback, channel_number)
     return d.addCallback(TwistedChannel)
Пример #12
0
 def channel(self, channel_number=None):
     """
     Return a Deferred that fires with an instance of a wrapper aroud the
     Pika Channel class.
     """
     d = defer.Deferred()
     BaseConnection.channel(self, d.callback, channel_number)
     return d.addCallback(TwistedChannel)
    def __init__(self, parameters=None, on_open_callback=None,
                 reconnection_strategy=None):

        # Validate we have Tornado installed
        if not IOLoop:
            raise ImportError("Tornado not installed")

        BaseConnection.__init__(self, parameters, on_open_callback,
                                reconnection_strategy)
Пример #14
0
    def __init__(self, parameters=None,
                 on_open_callback=None,
                 reconnection_strategy=None):

        # Validate we have Tornado installed
        if not IOLoop:
            raise ImportError("Tornado not installed")

        BaseConnection.__init__(self, parameters, on_open_callback,
                                reconnection_strategy)
Пример #15
0
    def _adapter_connect(self, host, port):
        # Connect (blockignly!) to the server
        BaseConnection._adapter_connect(self, host, port)
        # Pnce that's done, create an I/O loop by adapting the Twisted reactor
        self.ioloop = IOLoopReactorAdapter(self, reactor)
        # Set the I/O events we're waiting for (see IOLoopReactorAdapter
        # docstrings for why it's OK to pass None as the file descriptor)
        self.ioloop.update_handler(None, self.event_state)

        # Let everyone know we're connected
        self._on_connected()
Пример #16
0
    def _adapter_connect(self, host, port):
        # Connect (blockignly!) to the server
        BaseConnection._adapter_connect(self, host, port)
        # Pnce that's done, create an I/O loop by adapting the Twisted reactor
        self.ioloop = IOLoopReactorAdapter(self, reactor)
        # Set the I/O events we're waiting for (see IOLoopReactorAdapter
        # docstrings for why it's OK to pass None as the file descriptor)
        self.ioloop.update_handler(None, self.event_state)

        # Let everyone know we're connected
        self._on_connected()
Пример #17
0
    def __init__(self, parameters=None, on_open_callback=None,
                 reconnection_strategy=None, io_loop=None):

        # Validate we have Tornado installed
        if not IOLoop:
            raise ImportError("Tornado not installed")

        # Store the passed in io_loop (for example, for unit tests)
        self.tornado_loop = io_loop

        BaseConnection.__init__(self, parameters, on_open_callback,
                                reconnection_strategy)
Пример #18
0
    def _adapter_connect(self, host, port):
        """
        Connect to the given host and port
        """
        BaseConnection._adapter_connect(self, host, port)

        # Setup our and start our IOLoop and Poller
        self.ioloop = IOLoop.instance()
        self.ioloop.fileno = self.socket.fileno()
        self.ioloop.start_poller(self._handle_events, self.event_state)

        # Let everyone know we're connected
        self._on_connected()
Пример #19
0
    def _adapter_connect(self, host, port):
        """
        Connect to the given host and port
        """
        BaseConnection._adapter_connect(self, host, port)

        # Setup our ioloop
        self.ioloop = IOLoop.instance()

        # Add the ioloop handler for the event state
        self.ioloop.add_handler(self.socket.fileno(), self._handle_events,
                                self.event_state)

        # Let everyone know we're connected
        self._on_connected()
Пример #20
0
    def _adapter_connect(self):
        """
        Connect to the given host and port
        """
        BaseConnection._adapter_connect(self)

        # Setup the IOLoop
        self.ioloop = IOLoop(self._manage_event_state)

        # Setup our and start our IOLoop and Poller
        self.ioloop.start_poller(self._handle_events, self.event_state,
                                 self.socket.fileno())

        # Let everyone know we're connected
        self._on_connected()
    def _adapter_connect(self, host, port):
        """
        Connect to the given host and port
        """
        BaseConnection._adapter_connect(self, host, port)

        # Setup our ioloop
        self.ioloop = IOLoop.instance()

        # Add the ioloop handler for the event state
        self.ioloop.add_handler(self.socket.fileno(),
                                self._handle_events,
                                self.event_state)

        # Let everyone know we're connected
        self._on_connected()
Пример #22
0
    def __init__(self, parameters=None,
                 on_open_callback=None,
                 reconnection_strategy=None,
                 callback_interval=250,
                 io_loop=None):

        # Validate we have Tornado installed
        if not IOLoop:
            raise ImportError("Tornado not installed")

        self.callback_interval = callback_interval
        self._pc = None
        self._default_ioloop = io_loop or IOLoop.instance()

        BaseConnection.__init__(self, parameters, on_open_callback,
                                reconnection_strategy)
Пример #23
0
    def __init__(self,
                 parameters=None,
                 on_open_callback=None,
                 reconnection_strategy=None,
                 callback_interval=250,
                 io_loop=None):

        # Validate we have Tornado installed
        if not IOLoop:
            raise ImportError("Tornado not installed")

        self.callback_interval = callback_interval
        self._pc = None
        self._default_ioloop = io_loop or IOLoop.instance()

        BaseConnection.__init__(self, parameters, on_open_callback,
                                reconnection_strategy)
Пример #24
0
    def __init__(self, parameters=None,
                 on_open_callback=None,
                 reconnection_strategy=None,
                 callback_interval=250,
                 io_loop=None):

        # Validate we have Tornado installed
        if not IOLoop:
            raise ImportError("Tornado not installed")

        self.callback_interval = callback_interval
        self._pc = None
        self._default_ioloop = io_loop or IOLoop.instance()

        on_open_callback = stack_context.wrap(on_open_callback)
        
        with stack_context.StackContext(self._stack_context):
            BaseConnection.__init__(self, parameters, on_open_callback,
                                    reconnection_strategy, CallbackManager())
Пример #25
0
    def _adapter_connect(self, host, port):
        """
        Connect to the given host and port
        """
        BaseConnection._adapter_connect(self, host, port)

        # Setup our ioloop - only if we didn't already have one.
        if self.tornado_loop:
            self.ioloop = self.tornado_loop
        else:
            self.ioloop = IOLoop.instance()

        # Add the ioloop handler for the event state
        self.ioloop.add_handler(self.socket.fileno(),
                                self._handle_events,
                                self.event_state)

        # Let everyone know we're connected
        self._on_connected()
Пример #26
0
    def _adapter_connect(self):
        """
        Connect to the given host and port
        """
        BaseConnection._adapter_connect(self)

        # Setup our ioloop
        self.ioloop = IOLoop.instance()

        # Setup a periodic callbacks
        _pc = ioloop.PeriodicCallback(self._manage_event_state,
                                      0.25,
                                      self.ioloop)
        _pc.start()

        # Add the ioloop handler for the event state
        self.ioloop.add_handler(self.socket.fileno(),
                                self._handle_events,
                                self.event_state)

        # Let everyone know we're connected
        self._on_connected()
Пример #27
0
 def __init__(self, parameters):
     self.ready = defer.Deferred()
     BaseConnection.__init__(self, parameters, self.connectionReady)
     self.ioloop = IOLoopReactorAdapter(self, reactor)
Пример #28
0
 def __init__(self, parameters):
     self.ready = defer.Deferred()
     BaseConnection.__init__(self, parameters, self.connectionReady)
Пример #29
0
 def __init__(self, parameters=None, on_open_callback=None,
              reconnection_strategy=None):
     # Run our base connection init
     BaseConnection.__init__(self, parameters, on_open_callback,
                             reconnection_strategy)
Пример #30
0
    def __init__(self, parameters=None, on_open_callback=None, reconnection_strategy=None):
        # Setup the IOLoop
        self.ioloop = IOLoop.instance()

        # Run our base connection init
        BaseConnection.__init__(self, parameters, on_open_callback, reconnection_strategy)
Пример #31
0
 def __init__(self, parameters):
     self.ready = defer.Deferred()
     BaseConnection.__init__(self, parameters, self.connectionReady)
     self.ioloop = IOLoopReactorAdapter(self, reactor)