【完美解决】使用flask的run启动debug来运行puppeteer,报错【signal only works in main thread 】的解决方案
解决方案:puppeteer在初始化launch时,必须增加以下的参数【handleSIGINT=False, handleSIGTERM=False, handleSIGHUP=False】才能使得flask的run-debug模式启动也能正常运行!
puppeteer官方文档:https://miyakogi.github.io/pyppeteer/reference.html#launcher
_browser = await launch( { "headless": _headless, "defaultViewport": _defaultViewport, "args": _args, "handleSIGINT": False, "handleSIGTERM": False, "handleSIGHUP": False })
解决方案的思路来源:
1、https://xbuba.com/questions/53679905
2、https://stackoom.com/question/3dEav/%E5%9C%A8FLASK%E4%B8%AD%E8%BF%90%E8%A1%8Cpypupeteer%E4%BC%9A%E4%BA%A7%E7%94%9FValueError-%E4%BF%A1%E5%8F%B7%E4%BB%85%E5%9C%A8%E4%B8%BB%E7%BA%BF%E7%A8%8B%E4%B8%AD%E6%9C%89%E6%95%88
转自:https://blog.csdn.net/weixin_43343144/article/details/110203479