Good Day, this should be fairly straight forward, but my googling and experimenting is not working.
I have a scraping script in python that uses Selenium/geckodriver/Firefox that runs on an Ubuntu 18 server. Sometimes it does not close properly and Selenium will crash midscript but it leaves many Web Content
processes open. If not closed they use up all the memory and then selenium can no longer open and the script fails.
If I run from the command line: pkill 'Web Content'
it will kill those processes and free up the memory.
In my python script I use the subprocess
module to try and automate this upon Selenium crashing. I've tried a number of options including:
subprocess.call("pkill 'Web Content'".split())
subprocess.call("pkill 'Web\ Content'".split())
subprocess.call("pkill Web\ Content".split())
subprocess.call("pkill -f Web\ Content".split())
And all of these throw the same error: pkill: only one pattern can be provided
Yet, if I do something like subprocess.call("pkill firefox".split())
the code is able to run without an error.
What must I do to resolve this issue? Thank you.