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


Python CircusSocket.load_from_config方法代码示例

本文整理汇总了Python中circus.sockets.CircusSocket.load_from_config方法的典型用法代码示例。如果您正苦于以下问题:Python CircusSocket.load_from_config方法的具体用法?Python CircusSocket.load_from_config怎么用?Python CircusSocket.load_from_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在circus.sockets.CircusSocket的用法示例。


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

示例1: load_from_config

# 需要导入模块: from circus.sockets import CircusSocket [as 别名]
# 或者: from circus.sockets.CircusSocket import load_from_config [as 别名]
    def load_from_config(cls, config_file):
        cfg = get_config(config_file)

        watchers = []
        for watcher in cfg.get('watchers', []):
            watchers.append(Watcher.load_from_config(watcher))

        sockets = []
        for socket in cfg.get('sockets', []):
            sockets.append(CircusSocket.load_from_config(socket))

        httpd = cfg.get('httpd', False)
        if httpd:
            # controlling that we have what it takes to run the web UI
            # if something is missing this will tell the user
            try:
                import circusweb     # NOQA
            except ImportError:
                logger.error('You need to install circus-web')
                sys.exit(1)

        # creating arbiter
        arbiter = cls(watchers, cfg['endpoint'], cfg['pubsub_endpoint'],
                      check_delay=cfg.get('check_delay', 1.),
                      prereload_fn=cfg.get('prereload_fn'),
                      stats_endpoint=cfg.get('stats_endpoint'),
                      plugins=cfg.get('plugins'), sockets=sockets,
                      warmup_delay=cfg.get('warmup_delay', 0),
                      httpd=httpd,
                      httpd_host=cfg.get('httpd_host', 'localhost'),
                      httpd_port=cfg.get('httpd_port', 8080),
                      debug=cfg.get('debug', False),
                      ssh_server=cfg.get('ssh_server', None))

        return arbiter
开发者ID:alessandrod,项目名称:circus,代码行数:37,代码来源:arbiter.py

示例2: load_from_config

# 需要导入模块: from circus.sockets import CircusSocket [as 别名]
# 或者: from circus.sockets.CircusSocket import load_from_config [as 别名]
    def load_from_config(cls, config_file):
        cfg = get_config(config_file)

        # hack reload ioloop to use the monkey patched version
        reload(ioloop)

        watchers = []
        for watcher in cfg.get('watchers', []):
            watchers.append(Watcher.load_from_config(watcher))

        sockets = []
        for socket in cfg.get('sockets', []):
            sockets.append(CircusSocket.load_from_config(socket))

        # creating arbiter
        arbiter = cls(watchers, cfg['endpoint'], cfg['pubsub_endpoint'],
                      check_delay=cfg.get('check_delay', 1.),
                      prereload_fn=cfg.get('prereload_fn'),
                      stats_endpoint=cfg.get('stats_endpoint'),
                      plugins=cfg.get('plugins'), sockets=sockets,
                      warmup_delay=cfg.get('warmup_delay', 0),
                      httpd=cfg.get('httpd', False),
                      httpd_host=cfg.get('httpd_host', 'localhost'),
                      httpd_port=cfg.get('httpd_port', 8080))

        return arbiter
开发者ID:mineo,项目名称:circus,代码行数:28,代码来源:arbiter.py

示例3: _get_sockets_fds

# 需要导入模块: from circus.sockets import CircusSocket [as 别名]
# 或者: from circus.sockets.CircusSocket import load_from_config [as 别名]
    def _get_sockets_fds(self):
        """Returns sockets dict. If this worker's cmd indicates use of
        a SO_REUSEPORT socket, a new socket is created and bound. This
        new socket's FD replaces original socket's FD in returned dict.
        This method populates `self._sockets` list. This list should be
        let go after `fork()`.
        """
        sockets_fds = None

        if self.watcher is not None and self.watcher.sockets is not None:
            sockets_fds = self.watcher._get_sockets_fds()
            reuseport_sockets = tuple((sn, s) for (sn, s)
                                      in self.watcher.sockets.items()
                                      if s.so_reuseport)

            for sn, s in reuseport_sockets:
                # watcher.cmd uses this reuseport socket
                if 'circus.sockets.%s' % sn in self.watcher.cmd:
                    sock = CircusSocket.load_from_config(s._cfg)
                    sock.bind_and_listen()
                    # replace original socket's fd
                    sockets_fds[sn] = sock.fileno()
                    # keep new socket until fork returns
                    self._sockets.append(sock)

        return sockets_fds
开发者ID:SEJeff,项目名称:circus,代码行数:28,代码来源:process.py

示例4: load_from_config

# 需要导入模块: from circus.sockets import CircusSocket [as 别名]
# 或者: from circus.sockets.CircusSocket import load_from_config [as 别名]
    def load_from_config(cls, config_file):
        cfg = get_config(config_file)

        # hack reload ioloop to use the monkey patched version
        reload(ioloop)

        watchers = []
        for watcher in cfg.get("watchers", []):
            watchers.append(Watcher.load_from_config(watcher))

        sockets = []
        for socket in cfg.get("sockets", []):
            sockets.append(CircusSocket.load_from_config(socket))

        # creating arbiter
        arbiter = cls(
            watchers,
            cfg["endpoint"],
            cfg["pubsub_endpoint"],
            check_delay=cfg.get("check_delay", 1.0),
            prereload_fn=cfg.get("prereload_fn"),
            stats_endpoint=cfg.get("stats_endpoint"),
            plugins=cfg.get("plugins"),
            sockets=sockets,
        )

        return arbiter
开发者ID:jlebleu,项目名称:circus,代码行数:29,代码来源:arbiter.py

示例5: load_from_config

# 需要导入模块: from circus.sockets import CircusSocket [as 别名]
# 或者: from circus.sockets.CircusSocket import load_from_config [as 别名]
    def load_from_config(cls, config_file):
        cfg = get_config(config_file)

        watchers = []
        for watcher in cfg.get('watchers', []):
            watchers.append(Watcher.load_from_config(watcher))

        sockets = []
        for socket in cfg.get('sockets', []):
            sockets.append(CircusSocket.load_from_config(socket))

        # creating arbiter
        arbiter = cls(watchers, cfg['endpoint'], cfg['pubsub_endpoint'],
                      check_delay=cfg.get('check_delay', 1.),
                      prereload_fn=cfg.get('prereload_fn'),
                      stats_endpoint=cfg.get('stats_endpoint'),
                      plugins=cfg.get('plugins'), sockets=sockets,
                      warmup_delay=cfg.get('warmup_delay', 0),
                      httpd=cfg.get('httpd', False),
                      httpd_host=cfg.get('httpd_host', 'localhost'),
                      httpd_port=cfg.get('httpd_port', 8080),
                      debug=cfg.get('debug', False),
                      stream_backend=cfg.get('stream_backend', 'thread'),
                      ssh_server=cfg.get('ssh_server', None))

        return arbiter
开发者ID:dekkers,项目名称:circus,代码行数:28,代码来源:arbiter.py

示例6: test_issue310

# 需要导入模块: from circus.sockets import CircusSocket [as 别名]
# 或者: from circus.sockets.CircusSocket import load_from_config [as 别名]
    def test_issue310(self):
        """
        https://github.com/mozilla-services/circus/pull/310

        Allow $(circus.sockets.name) to be used in args.
        """
        conf = get_config(_CONF["issue310"])
        watcher = Watcher.load_from_config(conf["watchers"][0])
        socket = CircusSocket.load_from_config(conf["sockets"][0])
        watcher.initialize(None, {"web": socket}, None)
        process = Process(
            watcher._process_counter,
            watcher.cmd,
            args=watcher.args,
            working_dir=watcher.working_dir,
            shell=watcher.shell,
            uid=watcher.uid,
            gid=watcher.gid,
            env=watcher.env,
            rlimits=watcher.rlimits,
            spawn=False,
            executable=watcher.executable,
            use_fds=watcher.use_sockets,
            watcher=watcher,
        )

        fd = watcher._get_sockets_fds()["web"]
        formatted_args = process.format_args()

        self.assertEquals(formatted_args, ["foo", "--fd", str(fd)])
开发者ID:B-Rich,项目名称:circus,代码行数:32,代码来源:test_config.py

示例7: test_issue310

# 需要导入模块: from circus.sockets import CircusSocket [as 别名]
# 或者: from circus.sockets.CircusSocket import load_from_config [as 别名]
    def test_issue310(self):
        '''
        https://github.com/mozilla-services/circus/pull/310

        Allow $(circus.sockets.name) to be used in args.
        '''
        conf = get_config(_CONF['issue310'])
        watcher = Watcher.load_from_config(conf['watchers'][0])
        socket = CircusSocket.load_from_config(conf['sockets'][0])
        try:
            watcher.initialize(None, {'web': socket}, None)
            process = Process(watcher._nextwid, watcher.cmd,
                              args=watcher.args,
                              working_dir=watcher.working_dir,
                              shell=watcher.shell, uid=watcher.uid,
                              gid=watcher.gid, env=watcher.env,
                              rlimits=watcher.rlimits, spawn=False,
                              executable=watcher.executable,
                              use_fds=watcher.use_sockets,
                              watcher=watcher)

            sockets_fds = watcher._get_sockets_fds()
            formatted_args = process.format_args(sockets_fds=sockets_fds)

            fd = sockets_fds['web']
            self.assertEqual(formatted_args,
                             ['foo', '--fd', str(fd)])
        finally:
            socket.close()
开发者ID:SEJeff,项目名称:circus,代码行数:31,代码来源:test_config.py

示例8: test_reuseport_supported

# 需要导入模块: from circus.sockets import CircusSocket [as 别名]
# 或者: from circus.sockets.CircusSocket import load_from_config [as 别名]
    def test_reuseport_supported(self):
        config = {"name": "", "host": "localhost", "port": 0, "so_reuseport": True}

        sock = CircusSocket.load_from_config(config)
        sockopt = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT)

        self.assertEqual(sock.so_reuseport, True)
        self.assertNotEqual(sockopt, 0)
开发者ID:jsbronder,项目名称:circus,代码行数:10,代码来源:test_sockets.py

示例9: test_load_from_config_blocking

# 需要导入模块: from circus.sockets import CircusSocket [as 别名]
# 或者: from circus.sockets.CircusSocket import load_from_config [as 别名]
    def test_load_from_config_blocking(self):
        # test default to false
        config = {'name': 'somename', 'host': 'localhost', 'port': 0}
        sock = CircusSocket.load_from_config(config)
        self.assertEqual(sock.blocking, False)
        sock.bind_and_listen()
        self.assertTrue(is_nonblock(sock.fileno()))
        sock.close()

        # test when true
        config = {'name': 'somename', 'host': 'localhost', 'port': 0,
                  'blocking': True}
        sock = CircusSocket.load_from_config(config)
        self.assertEqual(sock.blocking, True)
        sock.bind_and_listen()
        self.assertFalse(is_nonblock(sock.fileno()))
        sock.close()
开发者ID:BrainBot,项目名称:circus,代码行数:19,代码来源:test_sockets.py

示例10: test_load_from_config_umask

# 需要导入模块: from circus.sockets import CircusSocket [as 别名]
# 或者: from circus.sockets.CircusSocket import load_from_config [as 别名]
 def test_load_from_config_umask(self):
     sockfile = self._get_tmp_filename()
     config = {'name': 'somename', 'path': sockfile, 'umask': 0}
     sock = CircusSocket.load_from_config(config)
     try:
         self.assertEqual(sock.umask, 0)
     finally:
         sock.close()
开发者ID:IsCoolEntertainment,项目名称:debpkg_circus,代码行数:10,代码来源:test_sockets.py

示例11: test_load_from_config_replace

# 需要导入模块: from circus.sockets import CircusSocket [as 别名]
# 或者: from circus.sockets.CircusSocket import load_from_config [as 别名]
    def test_load_from_config_replace(self):
        sockfile = self._get_file()

        config = {'name': 'somename', 'path': sockfile, 'replace': False}
        sock = CircusSocket.load_from_config(config)
        try:
            self.assertRaises(OSError, sock.bind_and_listen)
        finally:
            sock.close()

        config = {'name': 'somename', 'path': sockfile, 'replace': True}
        sock = CircusSocket.load_from_config(config)
        sock.bind_and_listen()
        try:
            self.assertEqual(sock.replace, True)
        finally:
            sock.close()
开发者ID:IsCoolEntertainment,项目名称:debpkg_circus,代码行数:19,代码来源:test_sockets.py

示例12: test_reuseport_supported

# 需要导入模块: from circus.sockets import CircusSocket [as 别名]
# 或者: from circus.sockets.CircusSocket import load_from_config [as 别名]
    def test_reuseport_supported(self):
        config = {'name': '', 'host': 'localhost', 'port': 0,
                  'so_reuseport': True}

        sock = CircusSocket.load_from_config(config)
        sockopt = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT)

        self.assertEqual(sock.so_reuseport, True)
        self.assertNotEqual(sockopt, 0)
开发者ID:SEJeff,项目名称:circus,代码行数:11,代码来源:test_sockets.py

示例13: test_load_from_config_umask

# 需要导入模块: from circus.sockets import CircusSocket [as 别名]
# 或者: from circus.sockets.CircusSocket import load_from_config [as 别名]
    def test_load_from_config_umask(self):
        fd, sockfile = tempfile.mkstemp()
        os.close(fd)
        os.remove(sockfile)

        config = {"name": "somename", "path": sockfile, "umask": 0}
        sock = CircusSocket.load_from_config(config)
        try:
            self.assertEqual(sock.umask, 0)
        finally:
            sock.close()
开发者ID:jsbronder,项目名称:circus,代码行数:13,代码来源:test_sockets.py

示例14: test_bind_to_interface

# 需要导入模块: from circus.sockets import CircusSocket [as 别名]
# 或者: from circus.sockets.CircusSocket import load_from_config [as 别名]
    def test_bind_to_interface(self):
        config = {"name": "", "host": "localhost", "port": 0, "interface": "lo"}

        sock = CircusSocket.load_from_config(config)
        self.assertEqual(sock.interface, config["interface"])
        sock.setsockopt = mock.Mock()
        try:
            sock.bind_and_listen()
            sock.setsockopt.assert_any_call(socket.SOL_SOCKET, IN.SO_BINDTODEVICE, config["interface"] + "\0")
        finally:
            sock.close()
开发者ID:jsbronder,项目名称:circus,代码行数:13,代码来源:test_sockets.py

示例15: test_inet6

# 需要导入模块: from circus.sockets import CircusSocket [as 别名]
# 或者: from circus.sockets.CircusSocket import load_from_config [as 别名]
 def test_inet6(self):
     config = {"name": "", "host": "::1", "port": 0, "family": "AF_INET6"}
     sock = CircusSocket.load_from_config(config)
     self.assertEqual(sock.host, config["host"])
     self.assertEqual(sock.port, config["port"])
     sock.setsockopt = mock.Mock()
     try:
         sock.bind_and_listen()
         # we should have got a port set
         self.assertNotEqual(sock.port, 0)
     finally:
         sock.close()
开发者ID:jsbronder,项目名称:circus,代码行数:14,代码来源:test_sockets.py


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