Rarely I receive the following error:
我很少收到以下错误:
Exception in thread Thread-1240:
Traceback (most recent call last):
File "C:\Python26\lib\threading.py", line 534, in __bootstrap_inner
self.run()
File "C:\Python26\lib\threading.py", line 738, in run
self.function(*self.args, **self.kwargs)
File "C:\Users\MyUser\Documents\MyProject\a_script.py", line 33, in some_func
t.start()
File "C:\Python26\lib\threading.py", line 476, in start
_start_new_thread(self.__bootstrap, ())
error: can't start new thread
From here I gather I've hit some resource limit related to having too many threads in the same process. t.start()
(that line 33 above) starts a Timer object which indeed opens a new thread, however, my architecture is such that no more than a few timers should exist simultaneously.
从这里开始,我估计我遇到了一些资源限制,这与同一进程中有太多线程有关。t.start()(上面第33行)启动一个计时器对象,它确实打开了一个新的线程,但是,我的体系结构是,不应该同时存在超过几个计时器。
As this a rare event and I do not know how to recreate it, I would like to set it so that next time it happens I'll have all the info I need. This doesn't seem like a regular Python exception (no exception type specified...). Is it possible to try-except
it? Are there alternatives to catching what's going on beyond try-catch
?
由于这是一个罕见的事件,我不知道如何重新创建它,我想设置它,以便下次它发生时,我将拥有所有我需要的信息。这看起来不像是一个常规的Python异常(没有指定异常类型…)。可以试戴吗?有没有其他的办法去捕捉除了尝试之外的事情?
1 个解决方案
#1
3
It is a normal exception, actually it's thread.error ("thread" is the module which does all the low-level stuff). It's aliased in the "threading" module as ThreadError, so just catch threading.ThreadError.
这是一个正常的例外,实际上是线程。错误(“thread”是做所有低级工作的模块)。它在“线程”模块中别名为ThreadError,因此只需捕获thread .ThreadError。
#1
3
It is a normal exception, actually it's thread.error ("thread" is the module which does all the low-level stuff). It's aliased in the "threading" module as ThreadError, so just catch threading.ThreadError.
这是一个正常的例外,实际上是线程。错误(“thread”是做所有低级工作的模块)。它在“线程”模块中别名为ThreadError,因此只需捕获thread .ThreadError。