When I'm running my program that monitors a product page (with selenium) until the product is instock I sometimes get the following error after a while of running:
Error:
Traceback (most recent call last):
File "C:\Users\Julius\PycharmProjects\Fenix\venv\Klad2.py", line 132, in <module>
Start().layout()
File "C:\Users\Julius\PycharmProjects\Fenix\venv\Klad2.py", line 34, in layout
Monitor(url, delay, region, webhook, site).monitor()
File "C:\Users\Julius\PycharmProjects\Fenix\venv\Klad2.py", line 98, in monitor
driver.get(self.url)
File "C:\Users\Julius\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 330, in get
self.execute(Command.GET, {'url': url})
File "C:\Users\Julius\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 318, in execute
self.error_handler.check_response(response)
File "C:\Users\Julius\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 240, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: timeout: Timed out receiving message from renderer: 299.474
(Session info: headless chrome=81.0.4044.92)
Stacktrace:
Backtrace:
Ordinal0 [0x00F15F73+2449267]
Ordinal0 [0x00E48361+1606497]
Ordinal0 [0x00D3F969+522601]
Ordinal0 [0x00D376CF+489167]
Ordinal0 [0x00D36C8C+486540]
Ordinal0 [0x00D36FB5+487349]
Ordinal0 [0x00D3DDD4+515540]
Ordinal0 [0x00D43913+538899]
Ordinal0 [0x00D452CB+545483]
Ordinal0 [0x00D371ED+487917]
Ordinal0 [0x00D437CC+538572]
Ordinal0 [0x00CF3455+210005]
Ordinal0 [0x00CE9E5B+171611]
Ordinal0 [0x00CD1DD8+73176]
Ordinal0 [0x00CD2E50+77392]
Ordinal0 [0x00CD2DE9+77289]
Ordinal0 [0x00E5D8D7+1693911]
GetHandleVerifier [0x00FB4036+522726]
GetHandleVerifier [0x00FB3D74+522020]
GetHandleVerifier [0x00FC9187+609079]
GetHandleVerifier [0x00FB48A6+524886]
Ordinal0 [0x00E55CBC+1662140]
Ordinal0 [0x00E5F23B+1700411]
Ordinal0 [0x00E5F3A3+1700771]
Ordinal0 [0x00E75215+1790485]
BaseThreadInitThunk [0x76906359+25]
RtlGetAppContainerNamedObjectPath [0x77987B74+228]
RtlGetAppContainerNamedObjectPath [0x77987B44+180]
Does somebody know how to fix this?
The timeout happens when you execute the code at line 132 in Klad2.py. Catch the exception (try..except) and decide what to do about it. If this is fairly rare and you should expect an occasional timeout when asking for web data, you can probably just ignore it. More robust error handling would keep check for multiple consecutive failures, report a communication failure and either quit or fall into some sort of low rate limp mode until communication is reestablished.