コード例 #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
ファイル: select_connection.py プロジェクト: pierremarc/pika
 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
ファイル: twisted_connection.py プロジェクト: pierremarc/pika
 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
ファイル: tornado_connection.py プロジェクト: bergundy/pika
    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
ファイル: pyside_connection.py プロジェクト: inean/pika
 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
ファイル: twisted_connection.py プロジェクト: pierremarc/pika
 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)
コード例 #13
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)
コード例 #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
ファイル: twisted_connection.py プロジェクト: pierremarc/pika
    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
ファイル: tornado_connection.py プロジェクト: kaze/paasmaker
    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
ファイル: select_connection.py プロジェクト: samuel/pika
    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
ファイル: tornado_connection.py プロジェクト: daasara/riba
    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
ファイル: select_connection.py プロジェクト: pierremarc/pika
    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()
コード例 #21
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()
コード例 #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
ファイル: tornado_connection.py プロジェクト: pierremarc/pika
    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
ファイル: tornado_connection.py プロジェクト: bergundy/pika
    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
ファイル: tornado_connection.py プロジェクト: kaze/paasmaker
    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
ファイル: tornado_connection.py プロジェクト: curlup/pika
    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
ファイル: twisted_connection.py プロジェクト: nkvoll/pika
 def __init__(self, parameters):
     self.ready = defer.Deferred()
     BaseConnection.__init__(self, parameters, self.connectionReady)
コード例 #29
0
ファイル: select_connection.py プロジェクト: CashStar/pika
 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
ファイル: select_connection.py プロジェクト: samuel/pika
    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
ファイル: twisted_connection.py プロジェクト: pierremarc/pika
 def __init__(self, parameters):
     self.ready = defer.Deferred()
     BaseConnection.__init__(self, parameters, self.connectionReady)
     self.ioloop = IOLoopReactorAdapter(self, reactor)