I'm using Selenium to run tests using Chrome Webdriver. Most of the time script works fine, but sometimes it returns a Timeout error when initializing webdriver.Chrome() constructor.
Below is the error message I'm receiving.
Message: session not created
source-app-1 | from timeout: Timed out receiving message from renderer: 600.000
source-app-1 | (Session info: headless chrome=102.0.5005.182)
I see this failure at a rate of about 1 in 10 or sometimes about 1 in 20.
Below is the code when it sometimes hangs and returns the Timeout exception.
from selenium import webdriver
self.driver = webdriver.Chrome(executable_path=driver_executable_path,
chrome_options=driver_options)
ENVIRONMENT
The script runs inside the Docker container and below is my dockerfile.
FROM nginxinc/nginx-unprivileged:1-alpine
ENV PATH="/scripts:${PATH}"
USER root
# Install python/pip
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3=3.9.15-r0 py3-setuptools --repository=https://dl-cdn.alpinelinux.org/alpine/v3.15/main/
RUN ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --upgrade --no-cache pip
COPY ./requirements.txt /requirements.txt
RUN apk add --update --no-cache gcc libffi-dev libc-dev linux-headers openssl-dev cargo rust python3-dev libxml2-dev libxslt-dev jpeg-dev zlib-dev chromium chromium-chromedriver --repository=https://dl-cdn.alpinelinux.org/alpine/v3.15/main/
RUN pip3 install -r /requirements.txt
RUN mkdir -p /vol/static
RUN chmod 755 /vol/static
RUN mkdir /app
COPY . /app
WORKDIR /app
RUN adduser -D user
RUN chown -R user:user /vol
RUN chmod -R 755 /vol/web
CMD ["entrypoint.sh"]
Docker Compose
version: '3.7'
services:
app:
build:
context: .
command: sh -c "python start.py"
deploy:
resources:
limits:
cpus: "2"
memory: 2048M
reservations:
cpus: "0.25"
memory: 128M
volumes:
- .:/app
environment:
...
networks:
default:
external:
name: my-network