当前位置: 首页>>代码示例>>Python>>正文


Python base_connection.BaseConnection类代码示例

本文整理汇总了Python中pika.adapters.base_connection.BaseConnection的典型用法代码示例。如果您正苦于以下问题:Python BaseConnection类的具体用法?Python BaseConnection怎么用?Python BaseConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BaseConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _adapter_connect

    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)
开发者ID:bergundy,项目名称:pika,代码行数:27,代码来源:tornado_connection.py

示例2: _handle_disconnect

    def _handle_disconnect(self):
        """
        Called internally when we know our socket is disconnected already
        """
        self.stop_poller()

        BaseConnection._handle_disconnect(self)
开发者ID:KnightBaron,项目名称:pika,代码行数:7,代码来源:tornado_connection.py

示例3: _on_connected

 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()
开发者ID:bartekgorny,项目名称:pika,代码行数:7,代码来源:twisted_connection.py

示例4: _adapter_disconnect

    def _adapter_disconnect(self):
        """
        Disconnect from the RabbitMQ Broker
        """
        self.stop_poller()

        BaseConnection._adapter_disconnect(self)
开发者ID:KnightBaron,项目名称:pika,代码行数:7,代码来源:tornado_connection.py

示例5: _adapter_connect

 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()
开发者ID:inean,项目名称:pika,代码行数:8,代码来源:pyside_connection.py

示例6: channel

 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)
开发者ID:bartekgorny,项目名称:pika,代码行数:8,代码来源:twisted_connection.py

示例7: __init__

    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)
开发者ID:arbeit,项目名称:openquake-packages,代码行数:9,代码来源:tornado_connection.py

示例8: _adapter_connect

    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()
开发者ID:bartekgorny,项目名称:pika,代码行数:11,代码来源:twisted_connection.py

示例9: __init__

    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)
开发者ID:kaze,项目名称:paasmaker,代码行数:12,代码来源:tornado_connection.py

示例10: _adapter_connect

    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()
开发者ID:samuel,项目名称:pika,代码行数:13,代码来源:select_connection.py

示例11: _adapter_connect

    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()
开发者ID:arbeit,项目名称:openquake-packages,代码行数:16,代码来源:tornado_connection.py

示例12: __init__

    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)
开发者ID:KnightBaron,项目名称:pika,代码行数:16,代码来源:tornado_connection.py

示例13: _adapter_connect

    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()
开发者ID:kaze,项目名称:paasmaker,代码行数:19,代码来源:tornado_connection.py

示例14: __init__

    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())
开发者ID:bergundy,项目名称:pika,代码行数:19,代码来源:tornado_connection.py

示例15: _adapter_connect

    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()
开发者ID:curlup,项目名称:pika,代码行数:22,代码来源:tornado_connection.py


注:本文中的pika.adapters.base_connection.BaseConnection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。