gpt4 book ai didi

python - 引发的异常似乎没有被捕获

转载 作者:太空宇宙 更新时间:2023-11-03 21:44:27 24 4
gpt4 key购买 nike

我使用 futures.ProcessPoolExecutor(max_workers=4) 运行应用程序。在linux下,运行良好。在两个不同的 Macos 上,它卡住/锁定/我们不知道。当我们在 Macoss 上按下 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 block ,但堆栈跟踪使它看起来像是从未到达过。我是否应该在这里调查一些真正可疑的事情,或者仅仅是因为按下了 Ctrl+C 所以不再有异常处理程序工作?另外,有什么明显的原因可以解释为什么它可以在 linux 上运行而不是在 macOS 上运行吗?

谢谢!

最佳答案

您的 IndexError 已被捕获。理清交错的堆栈跟踪,似乎在处理 IndexError 时,KeyboardInterrupt 到达(在每个进程中)。以下行:

During handling of the above exception, another exception occurred:

表示implicit exception chaining 。在处理现有异常时发生了新异常,因此两个异常被附加在一起,并且两个堆栈跟踪都被打印。

关于python - 引发的异常似乎没有被捕获,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52598363/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com