本文整理匯總了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)
示例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