How can I catch CTRL+C (a KeyboardInterrupt) without causing the chromedriver to close. It closes the chromedriver when I run my script.py through cmd.
driver = webdriver.Chrome()
try:
while True:
#do stuff with chromedriver
except KeyboardInterrupt:
print "User pressed CTRL + C"
#do other stuff with chromedriver
It does catch the KeyboardInterrupt in my script, thus my script continues but the chromedriver also gets it and close itself.
EDIT 1:
The solution here doesn't work when you run the script through CMD or when you freeze the script with Pyinstaller and run it (IOError: [Errno 4] Interrupted function call
)
EDIT 2:
I also tried by making the script ignore the Errno 4 (using try
and except Exception
) but still has the same result (chromedriver closes) so in short, this solution does not help at all.