コード例 #1
0
    def connect(self, url=None, options=None, callback=None):
        if url is not None:
            self.url = url
        purl = urlparse(self.url)
        credentials = pika.PlainCredentials(purl.username, purl.password)
        virtual_host = purl.path[1:]
        host = purl.hostname
        port = purl.port

        options = options or {}
        options = dict([(k.lstrip('DEFAULT_').lower(), v)
                        for k, v in options.items()])
        options.update(host=host,
                       port=port,
                       virtual_host=virtual_host,
                       credentials=credentials)

        params = pika.ConnectionParameters(**options)
        try:
            TornadoConnection(params,
                              stop_ioloop_on_close=False,
                              on_open_callback=partial(self.on_connect,
                                                       callback),
                              custom_ioloop=self.io_loop)
        except AMQPConnectionError:
            logging.info('Retrying to connect in 2 seconds')
            self.io_loop.add_timeout(
                timedelta(seconds=2),
                partial(self.connect,
                        url=url,
                        options=options,
                        callback=callback))
コード例 #2
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
    def connect(self, url=None, options=None, callback=None):
        if url is not None:
            self.url = url
        purl = urlparse(self.url)
        credentials = pika.PlainCredentials(purl.username, purl.password)
        virtual_host = purl.path[1:]
        host = purl.hostname
        port = purl.port

        options = options or {}
        options = dict([(k.lstrip('DEFAULT_').lower(), v) for k, v in options.items()])
        options.update(host=host, port=port, virtual_host=virtual_host,
                       credentials=credentials)

        params = pika.ConnectionParameters(**options)
        try:
            TornadoConnection(params, stop_ioloop_on_close=False,
                              on_open_callback=partial(self.on_connect, callback),
                              custom_ioloop=self.io_loop)
        except AMQPConnectionError:
            logging.info('Retrying to connect in 2 seconds')
            self.io_loop.add_timeout(
                    timedelta(seconds=2),
                    partial(self.connect, url=url,
                            options=options, callback=callback))
コード例 #3
0
ファイル: test_app.py プロジェクト: chunyu-zhou/webssh
 def get_httpserver_options(self):
     options = super(TestApp, self).get_httpserver_options()
     options.update(max_body_size=max_body_size)
     return options