我们运行了很多scraper,结果似乎有很多额外的进程悬而未决。我们确实确保在运行结束时退出浏览器,但很明显,当刮擦崩溃或中断时,可能会发生一些事情。
当我运行"ps-auxwwwww"时,我看到(在Ubuntu 20.04.2 LTS系统上(:
root 875464 875463 5 13:45 ? 00:11:15 /usr/bin/python3 foo1.py
root 909167 909166 2 16:30 ? 00:00:52 /usr/bin/python3 foo2.py
root 911702 911701 0 16:31 ? 00:00:13 /usr/bin/python3 foo3.py
root 915807 915805 1 16:35 ? 00:00:22 /usr/bin/python3 foo4.py
root 917485 917484 0 16:36 ? 00:00:13 /usr/bin/python3 foo5.py
root 919214 919213 8 16:37 ? 00:02:01 /usr/bin/python3 foo6.py
root 921380 921379 15 16:40 ? 00:03:06 /usr/bin/python3 foo7.py
root 926541 926540 0 16:48 ? 00:00:04 /usr/bin/python3 foo8.py
我看到这个,我想,我们有8次刮伤。看来还可以。
但我也看到了这一点:
root 766621 1 12 10:25 ? 00:50:29 /usr/lib/firefox/firefox --marionette --headless --no-sandbox --disable-dev-shm-usage --ignore-certificate-errors user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 -no-remote -profile /tmp/rust_mozprofileMLcj81
root 766774 766621 26 10:25 ? 01:45:31 /usr/lib/firefox/firefox -contentproc -childID 1 -isForBrowser -prefsLen 1 -prefMapSize 233311 -jsInit 278680 -parentBuildID 20211028161635 -appdir /usr/lib/firefox/browser 766621 true tab
root 766813 766621 1 10:25 ? 00:04:52 /usr/lib/firefox/firefox -contentproc -childID 2 -isForBrowser -prefsLen 85 -prefMapSize 233311 -jsInit 278680 -parentBuildID 20211028161635 -appdir /usr/lib/firefox/browser 766621 true tab
root 766926 766621 0 10:25 ? 00:00:01 /usr/lib/firefox/firefox -contentproc -childID 3 -isForBrowser -prefsLen 7696 -prefMapSize 233311 -jsInit 278680 -parentBuildID 20211028161635 -appdir /usr/lib/firefox/browser 766621 true tab
这个:
root 916001 915970 21 16:35 ? 00:05:19 /usr/lib/firefox/firefox --marionette -headless start-maximized disable-infobars --disable-extensions --disable-application-cache --disable-gpu --no-sandbox --disable-dev-shm-usage --ignore-certificate-errors user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 -no-remote -profile /tmp/rust_mozprofileYc8Rmk
root 916120 916001 6 16:35 ? 00:01:38 /usr/lib/firefox/firefox -contentproc -childID 1 -isForBrowser -prefsLen 1 -prefMapSize 233359 -jsInit 278680 -parentBuildID 20211028161635 -appdir /usr/lib/firefox/browser 916001 true tab
root 916139 916001 1 16:35 ? 00:00:17 /usr/lib/firefox/firefox -contentproc -childID 2 -isForBrowser -prefsLen 85 -prefMapSize 233359 -jsInit 278680 -parentBuildID 20211028161635 -appdir /usr/lib/firefox/browser 916001 true tab
root 916210 916001 0 16:35 ? 00:00:00 /usr/lib/firefox/firefox -contentproc -childID 3 -isForBrowser -prefsLen 149 -prefMapSize 233359 -jsInit 278680 -parentBuildID 20211028161635 -appdir /usr/lib/firefox/browser 916001 true tab
root 916216 916001 0 16:35 ? 00:00:00 /usr/lib/firefox/firefox -contentproc -childID 4 -isForBrowser -prefsLen 149 -prefMapSize 233359 -jsInit 278680 -parentBuildID 20211028161635 -appdir /usr/lib/firefox/browser 916001 true tab
root 916251 916001 0 16:36 ? 00:00:00 /usr/lib/firefox/firefox -contentproc -childID 5 -isForBrowser -prefsLen 1074 -prefMapSize 233359 -jsInit 278680 -parentBuildID 20211028161635 -appdir /usr/lib/firefox/browser 916001 true tab
root 916432 916001 0 16:36 ? 00:00:00 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -prefsLen 7899 -prefMapSize 233359 -jsInit 278680 -parentBuildID 20211028161635 -appdir /usr/lib/firefox/browser 916001 true tab 392663 1 1 Apr05 ? 2-04:16:25 /usr/lib/firefox/firefox --marionette -headless start-maximized disable-infobars --disable-extensions --disable-application-cache --disable-gpu --no-sandbox --disable-dev-shm-usage --ignore-certificate-errors user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 -no-remote -profile /tmp/rust_mozprofileEHvISm
root 392826 392663 1 Apr05 ? 2-04:14:08 /usr/lib/firefox/firefox -contentproc -childID 2 -isForBrowser -prefsLen 85 -prefMapSize 233359 -jsInit 278680 -parentBuildID 20211028161635 -appdir /usr/lib/firefox/browser 392663 true tab
root 392877 392663 0 Apr05 ? 04:01:26 /usr/lib/firefox/firefox -contentproc -childID 3 -isForBrowser -prefsLen 85 -prefMapSize 233359 -jsInit 278680 -parentBuildID 20211028161635 -appdir /usr/lib/firefox/browser 392663 true tab
root 392881 392663 0 Apr05 ? 04:00:54 /usr/lib/firefox/firefox -contentproc -childID 4 -isForBrowser -prefsLen 85 -prefMapSize 233359 -jsInit 278680 -parentBuildID 20211028161635 -appdir /usr/lib/firefox/browser 392663 true tab
root 392927 392663 0 Apr05 ? 04:10:12 /usr/lib/firefox/firefox -contentproc -childID 5 -isForBrowser -prefsLen 1010 -prefMapSize 233359 -jsInit 278680 -parentBuildID 20211028161635 -appdir /usr/lib/firefox/browser 392663 true tab
root 393116 392663 0 Apr05 ? 00:29:37 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -prefsLen 7899 -prefMapSize 233359 -jsInit 278680 -parentBuildID 20211028161635 -appdir /usr/lib/firefox/browser 392663 true tab
所以我看到了这些进程家族,这是一个父进程,然后是一堆以它为父进程的子进程。
但我没有看到8个过程家族。我看到20套。
起初,我认为如果父进程的父进程是进程#1,那么这一定意味着存在问题。但是只有2个进程族的根在进程1。
那到底是怎么回事?
我有8个scrape在运行,我应该有数百个进程在运行?做什么?
我可以重新启动机器,但这似乎很难。我想我可以让我们的脚本把它们的进程号写进一些数据存储中,看看这些进程是否仍然存在。但我似乎应该能够从运行的系统中看到,这些进程是否连接在一起,是吗?
有什么建议吗?
我们也有同样的问题,但我现在对有了更多的了解
多进程Firefox,也称为"电解";(通常简称为"e10s"(,通过分离Web内容和Firefox UI进程,为您的浏览体验提供了重大改进。这意味着,当网页消耗了你电脑的大部分处理能力时,你的选项卡、按钮和菜单不会锁定。
您拥有大量firefox-contentproc的原因可能是您确实杀死了主要的firefox进程,但不幸的是,这并没有杀死子进程。
这些都在附近徘徊,这就是你看到它们的原因。
我们需要实现自定义逻辑来杀死";"手工";子流程。
有关这些过程的更多信息,请参阅https://wiki.mozilla.org/Electrolysis.