Skip to Content
Menu
This question has been flagged
4 Replies
4435 Views

Hi everyone, I'm trying to trigger a very simple web scraper from Odoo. Right now, all I am trying to do is to instantiate a webdriver.Chrome object inside one of my model's functions, that is triggered by a button on my form view.

I am able to run this code as a separate python script (simply doing python my_script.py) which proves that Selenium is correctly configured in my system. However, it seems like the Odoo server's threads have a problem running it:

selenium\.common\.exceptions\.WebDriverException:\ Message:\ Service\ /root/\.wdm/drivers/chromedriver/linux64/103.0.5060.53/chromedriver unexpectedly exited. Status code was: -5

I have spent several hours trying to understand what is going on, but to no avail. Things I've tried so far include using both Chrome, Chromium and Firefox; tried every single combination of Webdriver parameters (headless, etc.); trying giving full permissions on chromedriver, chrome and chromium executables (chmod 777); running odoo with and without sudo.

Unfortauntely nothing worked so far, so I started looking into Odoo's ThreadedServer code, so see if I found any reason why Selenium's subprocess.Popen calls wouldn't work, but unfortunately this is so beyond my knowledge that I don't even know what to Google!

Any insights would be greatly appreciated... thanks!

Avatar
Discard
Best Answer

The problem is related to limit_memory_hard. Increase it and it will work properly. I had the same issue. 

Avatar
Discard

I set it like limit_memory_hard=2684354560
but still the same

You need to increase it even more.

Oh yeah I agree, with
limit_memory_hard=99999999999
It works all okay, this was so strange, I wonder how you could find such resolution, thanks a lot

All thanks to your question! You inspired me the idea, and after a lot of test I was able to figure it out. Selenium is opening a browser, but Odoo limits the memory of the thread. It closes abruptly due to that limit. For that reason, it is necessary to increase it so much.

Best Answer

Hi, i try to apply the answer of Enric Tobella Alomar , but doesnt works for me, stay raising the error  "Status code was: -5". Im doing good?  

i go to the "odoo.conf" and add the next line:
limit_memory_hard=999999999999

its right like this?

Avatar
Discard
Best Answer

Please add the following line before creating the driver object.

https://github.com/Vauxoo/odoo-selenium/blob/main/src/odoo_selenium/selenium.py#L88

Avatar
Discard
Best Answer

I have the same error, I am working in Odoo 14 CE, Ubuntu 20, 8 GB Memory and 4 vCPUs, Any suggestions?

Avatar
Discard
Author

I wasn't able to fix it, so what I did was I delegated the Selenium code to a small HTTP server running side on the same machine as my Odoo instance, and I just send requests from Odoo to the server.

Did you find any other solution? Also facing this issue

Hi Fred Nunes, How can I delegate the execution of selenium to a http server to send requests out of odoo? if you can share your solution it would be very helpful, thank you very much in advance

Hi Fred Nunes and Adnier Roselló.
Could you share your solution if you found it? Thank you.

Related Posts Replies Views Activity
1
Jun 25
1067
3
Jul 25
2800
1
May 25
1023
1
May 25
1264
4
May 25
2433