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


Python sys.is_finalizing方法代碼示例

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


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

示例1: test_is_finalizing

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import is_finalizing [as 別名]
def test_is_finalizing(self):
        self.assertIs(sys.is_finalizing(), False)
        # Don't use the atexit module because _Py_Finalizing is only set
        # after calling atexit callbacks
        code = """if 1:
            import sys

            class AtExit:
                is_finalizing = sys.is_finalizing
                print = print

                def __del__(self):
                    self.print(self.is_finalizing(), flush=True)

            # Keep a reference in the __main__ module namespace, so the
            # AtExit destructor will be called at Python exit
            ref = AtExit()
        """
        rc, stdout, stderr = assert_python_ok('-c', code)
        self.assertEqual(stdout.rstrip(), b'True') 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:22,代碼來源:test_sys.py

示例2: _get_emulated_is_finalizing

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import is_finalizing [as 別名]
def _get_emulated_is_finalizing() -> Callable[[], bool]:
        L = []  # type: List[None]
        atexit.register(lambda: L.append(None))

        def is_finalizing() -> bool:
            # Not referencing any globals here
            return L != []

        return is_finalizing 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:11,代碼來源:util.py

示例3: _get_emulated_is_finalizing

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import is_finalizing [as 別名]
def _get_emulated_is_finalizing():
        L = []
        atexit.register(lambda: L.append(None))

        def is_finalizing():
            # Not referencing any globals here
            return L != []

        return is_finalizing 
開發者ID:tp4a,項目名稱:teleport,代碼行數:11,代碼來源:util.py

示例4: close

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import is_finalizing [as 別名]
def close(self):
        super().close()
        if not sys.is_finalizing():
            for sig in list(self._signal_handlers):
                self.remove_signal_handler(sig)
        else:
            if self._signal_handlers:
                warnings.warn(f"Closing the loop {self!r} "
                              f"on interpreter shutdown "
                              f"stage, skipping signal handlers removal",
                              ResourceWarning,
                              source=self)
                self._signal_handlers.clear() 
開發者ID:CedricGuillemet,項目名稱:Imogen,代碼行數:15,代碼來源:unix_events.py

示例5: __del__

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import is_finalizing [as 別名]
def __del__(self):
        if (
            not self.asynchronous
            and hasattr(self, "_loop_runner")
            and not sys.is_finalizing()
        ):
            self.close() 
開發者ID:dask,項目名稱:dask-gateway,代碼行數:9,代碼來源:client.py


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