我使用futures.ProcessPoolExecutor(max_workers=4)
运行一个应用程序。在linux上,它运行良好。在两个不同的macOS上,它会冻结/锁定/我们不知道。当我们在macos上按CTRL + C时,将显示以下堆栈跟踪。
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
File "tests/parallel/recorder_tool.py", line 168, in __enter__
File "tests/parallel/recorder_tool.py", line 168, in __enter__
File "tests/parallel/recorder_tool.py", line 168, in __enter__
File "tests/parallel/recorder_tool.py", line 168, in __enter__
self.manager = self.__class__.managers.pop()
self.manager = self.__class__.managers.pop()
self.manager = self.__class__.managers.pop()
IndexError: pop from empty list
IndexError: pop from empty list
During handling of the above exception, another exception occurred:
self.manager = self.__class__.managers.pop()
IndexError: pop from empty list
During handling of the above exception, another exception occurred:
KeyboardInterrupt
During handling of the above exception, another exception occurred:
KeyboardInterrupt
IndexError: pop from empty list
KeyboardInterrupt
Exception ignored in: 'grpc._cython.cygrpc._next'
...
这是与IndexError
相关的代码示例。
try:
self.manager = self.__class__.managers.pop()
except IndexError:
self.manager = Factory.get_manager(get_conn)
有一个except IndexError
块,但是堆栈跟踪使它看起来好像从未到达过。我是否应该在这里进行一些研究,或者仅仅是因为按下了Ctrl + C就没有更多的异常处理程序了?另外,是否有任何明显的原因可以在Linux而不是macOS上运行?
谢谢!
答案 0 :(得分:0)
您的IndexError被捕获。解开交错的堆栈轨迹后,似乎在处理IndexError时KeyboardInterrupt到达了(在每个进程中)。以下行:
During handling of the above exception, another exception occurred:
表示implicit exception chaining。处理现有异常时发生了新的异常,因此将这两个异常附加在一起,并打印了两个堆栈跟踪。