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

posted @   石衣_2014  阅读(275)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示