from:https://stackoverflow.com/questions/366682/how-to-limit-execution-time-of-a-function-call-in-python当有些函数执行时间过长,影响整个程序运行时,可以使用此方法进行限制,超时会报错. from __future__ import with_statement # Required in 2.5 import signal from contextlib import contextmanag