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


Python process.fork_processes方法代码示例

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


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

示例1: start

# 需要导入模块: from tornado import process [as 别名]
# 或者: from tornado.process import fork_processes [as 别名]
def start(self, num_processes=1):
        u"""在 `.IOLoop` 中启动该服务.

        默认情况下, 我们在该进程中运行服务, 并且不会 fork 出任何额外
        的子进程.

        如果 num_processes 为 ``None`` 或 <= 0, 我们检测这台机器上可用的
        核心数并 fork 相同数量的子进程. 如果给定了 num_processes 并且 > 1,
        我们 fork 指定数量的子进程.

        因为我们使用进程而不是线程, 在任何服务代码之间没有共享内存.

        注意多进程模式和 autoreload 模块不兼容(或者是当 ``debug=True`` 时
        `tornado.web.Application` 的 ``autoreload=True`` 选项默认为 True).
        当使用多进程模式时, 直到 ``TCPServer.start(n)`` 调用后, 才能创建或者
        引用 IOLoops .
        """
        assert not self._started
        self._started = True
        if num_processes != 1:
            process.fork_processes(num_processes)
        sockets = self._pending_sockets
        self._pending_sockets = []
        self.add_sockets(sockets) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:26,代码来源:tcpserver.py

示例2: add_sockets

# 需要导入模块: from tornado import process [as 别名]
# 或者: from tornado.process import fork_processes [as 别名]
def add_sockets(self, sockets):
        """Makes this server start accepting connections on the given sockets.

        The ``sockets`` parameter is a list of socket objects such as
        those returned by `~tornado.netutil.bind_sockets`.
        `add_sockets` is typically used in combination with that
        method and `tornado.process.fork_processes` to provide greater
        control over the initialization of a multi-process server.
        """
        if self.io_loop is None:
            self.io_loop = IOLoop.current()

        for sock in sockets:
            self._sockets[sock.fileno()] = sock
            add_accept_handler(sock, self._handle_connection,
                               io_loop=self.io_loop) 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:18,代码来源:tcpserver.py

示例3: add_sockets

# 需要导入模块: from tornado import process [as 别名]
# 或者: from tornado.process import fork_processes [as 别名]
def add_sockets(self, sockets):
        """Makes this server start accepting connections on the given sockets.

        The ``sockets`` parameter is a list of socket objects such as
        those returned by `bind_sockets`.
        `add_sockets` is typically used in combination with that
        method and `tornado.process.fork_processes` to provide greater
        control over the initialization of a multi-process server.
        """
        if self.io_loop is None:
            self.io_loop = IOLoop.instance()

        for sock in sockets:
            self._sockets[sock.fileno()] = sock
            add_accept_handler(sock, self._handle_connection,
                               io_loop=self.io_loop) 
开发者ID:omererdem,项目名称:honeything,代码行数:18,代码来源:netutil.py

示例4: test_multi_process

# 需要导入模块: from tornado import process [as 别名]
# 或者: from tornado.process import fork_processes [as 别名]
def test_multi_process(self):
        self.assertFalse(IOLoop.initialized())
        port = get_unused_port()

        def get_url(path):
            return "http://127.0.0.1:%d%s" % (port, path)
        sockets = bind_sockets(port, "127.0.0.1")
        # ensure that none of these processes live too long
        signal.alarm(5)
        try:
            id = fork_processes(3, max_restarts=3)
        except SystemExit, e:
            # if we exit cleanly from fork_processes, all the child processes
            # finished with status 0
            self.assertEqual(e.code, 0)
            self.assertTrue(task_id() is None)
            for sock in sockets:
                sock.close()
            return 
开发者ID:omererdem,项目名称:honeything,代码行数:21,代码来源:process_test.py

示例5: add_sockets

# 需要导入模块: from tornado import process [as 别名]
# 或者: from tornado.process import fork_processes [as 别名]
def add_sockets(self, sockets):
        u"""使服务开始接收给定端口的连接.

        ``sockets`` 参数是一个 socket 对象的列表, 例如那些被
        `~tornado.netutil.bind_sockets` 所返回的对象.
        `add_sockets` 通常和 `tornado.process.fork_processes` 相结合使用,
        以便于在一个多进程服务初始化时提供更多控制.
        """
        if self.io_loop is None:
            self.io_loop = IOLoop.current()

        for sock in sockets:
            self._sockets[sock.fileno()] = sock
            add_accept_handler(sock, self._handle_connection,
                               io_loop=self.io_loop) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:17,代码来源:tcpserver.py

示例6: add_sockets

# 需要导入模块: from tornado import process [as 别名]
# 或者: from tornado.process import fork_processes [as 别名]
def add_sockets(self, sockets: Iterable[socket.socket]) -> None:
        """Makes this server start accepting connections on the given sockets.

        The ``sockets`` parameter is a list of socket objects such as
        those returned by `~tornado.netutil.bind_sockets`.
        `add_sockets` is typically used in combination with that
        method and `tornado.process.fork_processes` to provide greater
        control over the initialization of a multi-process server.
        """
        for sock in sockets:
            self._sockets[sock.fileno()] = sock
            self._handlers[sock.fileno()] = add_accept_handler(
                sock, self._handle_connection
            ) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:16,代码来源:tcpserver.py

示例7: start

# 需要导入模块: from tornado import process [as 别名]
# 或者: from tornado.process import fork_processes [as 别名]
def start(self, num_processes: Optional[int] = 1, max_restarts: int = None) -> None:
        """Starts this server in the `.IOLoop`.

        By default, we run the server in this process and do not fork any
        additional child process.

        If num_processes is ``None`` or <= 0, we detect the number of cores
        available on this machine and fork that number of child
        processes. If num_processes is given and > 1, we fork that
        specific number of sub-processes.

        Since we use processes and not threads, there is no shared memory
        between any server code.

        Note that multiple processes are not compatible with the autoreload
        module (or the ``autoreload=True`` option to `tornado.web.Application`
        which defaults to True when ``debug=True``).
        When using multiple processes, no IOLoops can be created or
        referenced until after the call to ``TCPServer.start(n)``.

        Values of ``num_processes`` other than 1 are not supported on Windows.

        The ``max_restarts`` argument is passed to `.fork_processes`.

        .. versionchanged:: 6.0

           Added ``max_restarts`` argument.
        """
        assert not self._started
        self._started = True
        if num_processes != 1:
            process.fork_processes(num_processes, max_restarts)
        sockets = self._pending_sockets
        self._pending_sockets = []
        self.add_sockets(sockets) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:37,代码来源:tcpserver.py

示例8: start

# 需要导入模块: from tornado import process [as 别名]
# 或者: from tornado.process import fork_processes [as 别名]
def start(self, num_processes=1):
        """Starts this server in the `.IOLoop`.

        By default, we run the server in this process and do not fork any
        additional child process.

        If num_processes is ``None`` or <= 0, we detect the number of cores
        available on this machine and fork that number of child
        processes. If num_processes is given and > 1, we fork that
        specific number of sub-processes.

        Since we use processes and not threads, there is no shared memory
        between any server code.

        Note that multiple processes are not compatible with the autoreload
        module (or the ``debug=True`` option to `tornado.web.Application`).
        When using multiple processes, no IOLoops can be created or
        referenced until after the call to ``TCPServer.start(n)``.
        """
        assert not self._started
        self._started = True
        if num_processes != 1:
            process.fork_processes(num_processes)
        sockets = self._pending_sockets
        self._pending_sockets = []
        self.add_sockets(sockets) 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:28,代码来源:tcpserver.py

示例9: add_sockets

# 需要导入模块: from tornado import process [as 别名]
# 或者: from tornado.process import fork_processes [as 别名]
def add_sockets(self, sockets):
        """Makes this server start accepting connections on the given sockets.

        The ``sockets`` parameter is a list of socket objects such as
        those returned by `~tornado.netutil.bind_sockets`.
        `add_sockets` is typically used in combination with that
        method and `tornado.process.fork_processes` to provide greater
        control over the initialization of a multi-process server.
        """
        for sock in sockets:
            self._sockets[sock.fileno()] = sock
            self._handlers[sock.fileno()] = add_accept_handler(
                sock, self._handle_connection) 
开发者ID:tp4a,项目名称:teleport,代码行数:15,代码来源:tcpserver.py

示例10: start

# 需要导入模块: from tornado import process [as 别名]
# 或者: from tornado.process import fork_processes [as 别名]
def start(self, num_processes=1):
        """Starts this server in the `.IOLoop`.

        By default, we run the server in this process and do not fork any
        additional child process.

        If num_processes is ``None`` or <= 0, we detect the number of cores
        available on this machine and fork that number of child
        processes. If num_processes is given and > 1, we fork that
        specific number of sub-processes.

        Since we use processes and not threads, there is no shared memory
        between any server code.

        Note that multiple processes are not compatible with the autoreload
        module (or the ``autoreload=True`` option to `tornado.web.Application`
        which defaults to True when ``debug=True``).
        When using multiple processes, no IOLoops can be created or
        referenced until after the call to ``TCPServer.start(n)``.
        """
        assert not self._started
        self._started = True
        if num_processes != 1:
            process.fork_processes(num_processes)
        sockets = self._pending_sockets
        self._pending_sockets = []
        self.add_sockets(sockets) 
开发者ID:tp4a,项目名称:teleport,代码行数:29,代码来源:tcpserver.py

示例11: start

# 需要导入模块: from tornado import process [as 别名]
# 或者: from tornado.process import fork_processes [as 别名]
def start(self, num_processes: Optional[int] = 1, max_restarts: int = None) -> None:
        """Starts this server in the `.IOLoop`.

        By default, we run the server in this process and do not fork any
        additional child process.

        If num_processes is ``None`` or <= 0, we detect the number of cores
        available on this machine and fork that number of child
        processes. If num_processes is given and > 1, we fork that
        specific number of sub-processes.

        Since we use processes and not threads, there is no shared memory
        between any server code.

        Note that multiple processes are not compatible with the autoreload
        module (or the ``autoreload=True`` option to `tornado.web.Application`
        which defaults to True when ``debug=True``).
        When using multiple processes, no IOLoops can be created or
        referenced until after the call to ``TCPServer.start(n)``.

        The ``max_restarts`` argument is passed to `.fork_processes`.

        .. versionchanged:: 6.0

           Added ``max_restarts`` argument.
        """
        assert not self._started
        self._started = True
        if num_processes != 1:
            process.fork_processes(num_processes, max_restarts)
        sockets = self._pending_sockets
        self._pending_sockets = []
        self.add_sockets(sockets) 
开发者ID:tp4a,项目名称:teleport,代码行数:35,代码来源:tcpserver.py

示例12: start

# 需要导入模块: from tornado import process [as 别名]
# 或者: from tornado.process import fork_processes [as 别名]
def start(self, num_processes=1):
        """Starts this server in the IOLoop.

        By default, we run the server in this process and do not fork any
        additional child process.

        If num_processes is ``None`` or <= 0, we detect the number of cores
        available on this machine and fork that number of child
        processes. If num_processes is given and > 1, we fork that
        specific number of sub-processes.

        Since we use processes and not threads, there is no shared memory
        between any server code.

        Note that multiple processes are not compatible with the autoreload
        module (or the ``debug=True`` option to `tornado.web.Application`).
        When using multiple processes, no IOLoops can be created or
        referenced until after the call to ``TCPServer.start(n)``.
        """
        assert not self._started
        self._started = True
        if num_processes != 1:
            process.fork_processes(num_processes)
        sockets = self._pending_sockets
        self._pending_sockets = []
        self.add_sockets(sockets) 
开发者ID:omererdem,项目名称:honeything,代码行数:28,代码来源:netutil.py


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