當前位置: 首頁>>代碼示例>>Python>>正文


Python process.task_id方法代碼示例

本文整理匯總了Python中tornado.process.task_id方法的典型用法代碼示例。如果您正苦於以下問題:Python process.task_id方法的具體用法?Python process.task_id怎麽用?Python process.task_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tornado.process的用法示例。


在下文中一共展示了process.task_id方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _reload_on_update

# 需要導入模塊: from tornado import process [as 別名]
# 或者: from tornado.process import task_id [as 別名]
def _reload_on_update(modify_times):
    if _reload_attempted:
        # We already tried to reload and it didn't work, so don't try again.
        return
    if process.task_id() is not None:
        # We're in a child process created by fork_processes.  If child
        # processes restarted themselves, they'd all restart and then
        # all call fork_processes again.
        return
    for module in list(sys.modules.values()):
        # Some modules play games with sys.modules (e.g. email/__init__.py
        # in the standard library), and occasionally this can cause strange
        # failures in getattr.  Just ignore anything that's not an ordinary
        # module.
        if not isinstance(module, types.ModuleType):
            continue
        path = getattr(module, "__file__", None)
        if not path:
            continue
        if path.endswith(".pyc") or path.endswith(".pyo"):
            path = path[:-1]
        _check_file(modify_times, path)
    for path in _watched_files:
        _check_file(modify_times, path) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:26,代碼來源:autoreload.py

示例2: _reload_on_update

# 需要導入模塊: from tornado import process [as 別名]
# 或者: from tornado.process import task_id [as 別名]
def _reload_on_update(modify_times: Dict[str, float]) -> None:
    if _reload_attempted:
        # We already tried to reload and it didn't work, so don't try again.
        return
    if process.task_id() is not None:
        # We're in a child process created by fork_processes.  If child
        # processes restarted themselves, they'd all restart and then
        # all call fork_processes again.
        return
    for module in list(sys.modules.values()):
        # Some modules play games with sys.modules (e.g. email/__init__.py
        # in the standard library), and occasionally this can cause strange
        # failures in getattr.  Just ignore anything that's not an ordinary
        # module.
        if not isinstance(module, types.ModuleType):
            continue
        path = getattr(module, "__file__", None)
        if not path:
            continue
        if path.endswith(".pyc") or path.endswith(".pyo"):
            path = path[:-1]
        _check_file(modify_times, path)
    for path in _watched_files:
        _check_file(modify_times, path) 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:26,代碼來源:autoreload.py

示例3: test_simple

# 需要導入模塊: from tornado import process [as 別名]
# 或者: from tornado.process import task_id [as 別名]
def test_simple(self):
        code = textwrap.dedent(
            """
            from tornado.ioloop import IOLoop
            from tornado.process import task_id
            from tornado.tcpserver import TCPServer

            server = TCPServer()
            server.bind(0, address='127.0.0.1')
            server.start(3)
            IOLoop.current().run_sync(lambda: None)
            print(task_id(), end='')
        """
        )
        out = self.run_subproc(code)
        self.assertEqual("".join(sorted(out)), "012") 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:18,代碼來源:tcpserver_test.py

示例4: test_advanced

# 需要導入模塊: from tornado import process [as 別名]
# 或者: from tornado.process import task_id [as 別名]
def test_advanced(self):
        code = textwrap.dedent(
            """
            from tornado.ioloop import IOLoop
            from tornado.netutil import bind_sockets
            from tornado.process import fork_processes, task_id
            from tornado.ioloop import IOLoop
            from tornado.tcpserver import TCPServer

            sockets = bind_sockets(0, address='127.0.0.1')
            fork_processes(3)
            server = TCPServer()
            server.add_sockets(sockets)
            IOLoop.current().run_sync(lambda: None)
            print(task_id(), end='')
        """
        )
        out = self.run_subproc(code)
        self.assertEqual("".join(sorted(out)), "012") 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:21,代碼來源:tcpserver_test.py

示例5: _reload_on_update

# 需要導入模塊: from tornado import process [as 別名]
# 或者: from tornado.process import task_id [as 別名]
def _reload_on_update(modify_times):
    if _reload_attempted:
        # We already tried to reload and it didn't work, so don't try again.
        return
    if process.task_id() is not None:
        # We're in a child process created by fork_processes.  If child
        # processes restarted themselves, they'd all restart and then
        # all call fork_processes again.
        return
    for module in sys.modules.values():
        # Some modules play games with sys.modules (e.g. email/__init__.py
        # in the standard library), and occasionally this can cause strange
        # failures in getattr.  Just ignore anything that's not an ordinary
        # module.
        if not isinstance(module, types.ModuleType):
            continue
        path = getattr(module, "__file__", None)
        if not path:
            continue
        if path.endswith(".pyc") or path.endswith(".pyo"):
            path = path[:-1]
        _check_file(modify_times, path)
    for path in _watched_files:
        _check_file(modify_times, path) 
開發者ID:viewfinderco,項目名稱:viewfinder,代碼行數:26,代碼來源:autoreload.py

示例6: test_advanced

# 需要導入模塊: from tornado import process [as 別名]
# 或者: from tornado.process import task_id [as 別名]
def test_advanced(self):
        code = textwrap.dedent("""
            from __future__ import print_function
            from tornado.ioloop import IOLoop
            from tornado.netutil import bind_sockets
            from tornado.process import fork_processes, task_id
            from tornado.ioloop import IOLoop
            from tornado.tcpserver import TCPServer

            sockets = bind_sockets(0, address='127.0.0.1')
            fork_processes(3)
            server = TCPServer()
            server.add_sockets(sockets)
            IOLoop.current().run_sync(lambda: None)
            print(task_id(), end='')
        """)
        out = self.run_subproc(code)
        self.assertEqual(''.join(sorted(out)), "012") 
開發者ID:tp4a,項目名稱:teleport,代碼行數:20,代碼來源:tcpserver_test.py

示例7: test_multi_process

# 需要導入模塊: from tornado import process [as 別名]
# 或者: from tornado.process import task_id [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

示例8: tearDown

# 需要導入模塊: from tornado import process [as 別名]
# 或者: from tornado.process import task_id [as 別名]
def tearDown(self):
        if task_id() is not None:
            # We're in a child process, and probably got to this point
            # via an uncaught exception.  If we return now, both
            # processes will continue with the rest of the test suite.
            # Exit now so the parent process will restart the child
            # (since we don't have a clean way to signal failure to
            # the parent that won't restart)
            logging.error("aborting child process from tearDown")
            logging.shutdown()
            os._exit(1)
        # In the surviving process, clear the alarm we set earlier
        signal.alarm(0)
        super(ProcessTest, self).tearDown() 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:16,代碼來源:process_test.py

示例9: test_simple

# 需要導入模塊: from tornado import process [as 別名]
# 或者: from tornado.process import task_id [as 別名]
def test_simple(self):
        code = textwrap.dedent("""
            from __future__ import print_function
            from tornado.ioloop import IOLoop
            from tornado.process import task_id
            from tornado.tcpserver import TCPServer

            server = TCPServer()
            server.bind(0, address='127.0.0.1')
            server.start(3)
            IOLoop.current().run_sync(lambda: None)
            print(task_id(), end='')
        """)
        out = self.run_subproc(code)
        self.assertEqual(''.join(sorted(out)), "012") 
開發者ID:tp4a,項目名稱:teleport,代碼行數:17,代碼來源:tcpserver_test.py

示例10: _reload_on_update

# 需要導入模塊: from tornado import process [as 別名]
# 或者: from tornado.process import task_id [as 別名]
def _reload_on_update(modify_times):
    global needs_to_reload
    if _reload_attempted:
        # We already tried to reload and it didn't work, so don't try again.
        return
    if process.task_id() is not None:
        # We're in a child process created by fork_processes.  If child
        # processes restarted themselves, they'd all restart and then
        # all call fork_processes again.
        return
    for module in list(sys.modules.values()):
        # Some modules play games with sys.modules (e.g. email/__init__.py
        # in the standard library), and occasionally this can cause strange
        # failures in getattr.  Just ignore anything that's not an ordinary
        # module.
        if not isinstance(module, types.ModuleType):
            continue
        path = getattr(module, "__file__", None)
        if not path:
            continue
        if path.endswith(".pyc") or path.endswith(".pyo"):
            path = path[:-1]

        result = _check_file(modify_times, module, path)
        if result is False:
            # If any files errored, we abort this attempt at reloading.
            return
        if result is True:
            # If any files had actual changes that import properly,
            # we'll plan to reload the next time we run with no files
            # erroring.
            needs_to_reload = True

    if needs_to_reload:
        _reload() 
開發者ID:zulip,項目名稱:zulip,代碼行數:37,代碼來源:autoreload.py


注:本文中的tornado.process.task_id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。