本文整理汇总了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