【完美解決】使用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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章