有没有一种方法可以确定Python是否正在关闭?
基本上:
def Foo(object):
def __del__(self):
if PYTHON_IS_EXITING:
do_this
else:
do_that
foo1 = Foo()
del foo1 # calls do_that
foo2 # calls do_this when python exits
这里的上下文是当Python退出时,multiprocessing.ThreadPool不起作用,而do_that将并行执行,而do_this将按顺序执行。
谢谢。