當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。