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


Python util._exit_function方法代碼示例

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


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

示例1: _test_finalize

# 需要導入模塊: from multiprocessing import util [as 別名]
# 或者: from multiprocessing.util import _exit_function [as 別名]
def _test_finalize(cls, conn):
        class Foo(object):
            pass

        a = Foo()
        util.Finalize(a, conn.send, args=('a',))
        del a           # triggers callback for a

        b = Foo()
        close_b = util.Finalize(b, conn.send, args=('b',))
        close_b()       # triggers callback for b
        close_b()       # does nothing because callback has already been called
        del b           # does nothing because callback has already been called

        c = Foo()
        util.Finalize(c, conn.send, args=('c',))

        d10 = Foo()
        util.Finalize(d10, conn.send, args=('d10',), exitpriority=1)

        d01 = Foo()
        util.Finalize(d01, conn.send, args=('d01',), exitpriority=0)
        d02 = Foo()
        util.Finalize(d02, conn.send, args=('d02',), exitpriority=0)
        d03 = Foo()
        util.Finalize(d03, conn.send, args=('d03',), exitpriority=0)

        util.Finalize(None, conn.send, args=('e',), exitpriority=-10)

        util.Finalize(None, conn.send, args=('STOP',), exitpriority=-100)

        # call multiprocessing's cleanup function then exit process without
        # garbage collecting locals
        util._exit_function()
        conn.close()
        os._exit(0) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:38,代碼來源:test_multiprocessing.py

示例2: post_worker_init

# 需要導入模塊: from multiprocessing import util [as 別名]
# 或者: from multiprocessing.util import _exit_function [as 別名]
def post_worker_init(worker):
    worker.log.debug('Unregistering usage tracking in worker process')
    atexit.unregister(_exit_function)  # Shutting down Gunicorn gracefully 
開發者ID:bentoml,項目名稱:BentoML,代碼行數:5,代碼來源:gunicorn_config.py


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