Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 PyV8 运行不受信任的 javascript。如何检测并杀死其中包含无限循环或长时间运行循环的 javascript?我想告诉 v8 运行 javascript,如果它没有在 0.1 秒内完成,它会因超时而失败。
如果是 python,你可以使用 Interrupting cow:
from interruptingcow import timeout try: with timeout(5, exception=RuntimeError): # perform a potentially very slow operation pass except RuntimeError: print "didn't finish within 5 seconds"
https://bitbucket.org/evzijst/interruptingcow