[Perfect solution] Use flask's run to start debug to run puppeteer, and report an error [signal only works in main thread] solution

Solution: When puppeteer initializes launch, it must add the following parameters [handleSIGINT=False, handleSIGTERM=False, handleSIGHUP=False] to make flask's run-debug mode start and run normally!

Official puppeteer document: https://miyakogi.github.io/pyppeteer/reference.html#launcher

 _browser = await launch(
            {
                "headless": _headless,
                "defaultViewport": _defaultViewport,
                "args": _args,
                "handleSIGINT": False,
                "handleSIGTERM": False,
                "handleSIGHUP": False
            })

The source of ideas for the solution:

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

 

Guess you like

Origin blog.csdn.net/weixin_43343144/article/details/110203479