Skip to content

Commit

Permalink
Revamp timeout handling in _wait_graph_page_ready
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Dec 9, 2022
1 parent 89e3c6e commit 36e3a91
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ resource_*.py
environment.yml
docs_environment.yml
esss_environment.yml
mxgraph/
2 changes: 1 addition & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def docs(ctx, python_version=None):
@invoke.task
def test(ctx):
print_message('test'.format(), color=Fore.BLUE, bright=True)
cmd = 'pytest --cov=qmxgraph --timeout=30 -v --durations=10'
cmd = 'pytest --cov=qmxgraph --timeout=60 -v --durations=10'

import subprocess

Expand Down
17 changes: 6 additions & 11 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ def pytest_configure(config):
if os.path.isfile(lock_file):
os.remove(lock_file)

import socket

socket.setdefaulttimeout(15.0)


# Fixtures --------------------------------------------------------------------

Expand Down Expand Up @@ -949,25 +945,24 @@ def _wait_graph_page_ready(host, selenium):
import socket
from selenium.common.exceptions import TimeoutException

timeout = 15
timeout = 30
timeout_exceptions = (TimeoutException, TimeoutError, socket.timeout)
selenium.set_page_load_timeout(1)
selenium.set_page_load_timeout(timeout)
refresh = True
try:
selenium.get(host.address)
refresh = False
except timeout_exceptions:
pass

tries = 3
if refresh:
for n in range(timeout):
for n in range(tries):
try:
selenium.refresh()
break
except timeout_exceptions:
pass
else:
raise TimeoutException("All page load tries resulted in timeout")
if n == tries - 1:
raise

from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
Expand Down

0 comments on commit 36e3a91

Please sign in to comment.