0

I have a StockBuyingBot that I dubbed Kenbot which I have running for a year now trying to iron out some bugs along the way.

Kenbot runs via my Synology NAS on a docker image (selenium/standalone-chrome:latest) every morning before the market opens it will place orders for few stocks.

Now when the code gets to driver.get it throws the following traceback:

Traceback (most recent call last):
  File "/volume1/homes/admin/Drive/stock/bursa/bursaqr_announcer.py", line 385, in <module>
    main()
  File "/volume1/homes/admin/Drive/stock/bursa/bursaqr_announcer.py", line 379, in main
    BursaQR().application(sc, px, eg)
  File "/volume1/homes/admin/Drive/stock/bursa/bursaqr_announcer.py", line 338, in application
    sc.producer()
  File "/volume1/homes/admin/Drive/stock/bursa/bursaqr_announcer.py", line 73, in producer
    df = screener(
  File "/volume1/homes/admin/Drive/stock/filehandler/file_handler2.py", line 121, in wrapper
    df = func(*args, **kwargs)
  File "/volume1/homes/admin/Drive/stock/filter/screener.py", line 23, in screener
    acc, pri = getet()
  File "/volume1/homes/admin/Drive/stock/filter/get_ETfilter.py", line 47, in get_ETfilter
    driver.get("https://trade.STOCKBROKING.com.my/STOCKBROKING/research/researchvalidate.aspx?StkCode")
  File "/volume1/homes/admin/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 333, in get
    self.execute(Command.GET, {'url': url})
  File "/volume1/homes/admin/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/volume1/homes/admin/venv/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: Unable to execute request for an existing session: java.util.concurrent.TimeoutException
Build info: version: '4.0.0', revision: '3a21814679'
System info: host: '2062b5c9a28e', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.59+', java.version: '11.0.11'
Driver info: driver.version: unknown
mrkgoh
  • 31
  • 2
  • 7

2 Answers2

0

This error message...

selenium.common.exceptions.TimeoutException: Message: Unable to execute request for an existing session: java.util.concurrent.TimeoutException
Build info: version: '4.0.0', revision: '3a21814679'
System info: host: '2062b5c9a28e', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.59+', java.version: '11.0.11'
Driver info: driver.version: unknown

...implies that an existing Selenium driven ChromeDriver initiated Browsing Context still exists. Hence a new session can't be initiated.


Solution

Always invoke driver.quit() within tearDown(){} method to close & destroy the current WebDriver and Web Client instances gracefully before initializing a new session.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

Previous session is not destroyed. Use

driver.quit()

to close and destroy session.