Skip to content

Commit 6c05174

Browse files
committed
max_retries
1 parent 2e0a7c6 commit 6c05174

File tree

1 file changed

+13
-4
lines changed
  • src/python/espressomd

1 file changed

+13
-4
lines changed

src/python/espressomd/zn.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
import secrets
2828
import time
2929
import urllib.parse
30+
import requests
31+
import requests.adapters
32+
import logging
3033
import typing
3134
import scipy.spatial.transform
32-
import httpx
3335

3436
from espressomd.plugins import ase
3537

@@ -250,13 +252,20 @@ def __init__(self,
250252

251253
# Check that the server is up
252254
max_wait_iterations = 60
255+
previous_logging_level = logging.root.manager.disable
253256
while True:
254257
try:
255-
r = httpx.get(f"{self.url}:{self.SERVER_PORT}/health")
256-
if r.status_code == 200:
258+
logging.disable(logging.WARNING)
259+
session = requests.Session()
260+
adapter = requests.adapters.HTTPAdapter(max_retries=1)
261+
req = session.mount(f"{self.url}:{self.SERVER_PORT}", adapter)
262+
req = session.get(f"{self.url}:{self.SERVER_PORT}/health")
263+
if req.status_code == 200:
264+
logging.disable(previous_logging_level)
257265
break
258-
except httpx.RequestError:
266+
except Exception:
259267
pass
268+
logging.disable(previous_logging_level)
260269
time.sleep(0.5)
261270
max_wait_iterations -= 1
262271
if max_wait_iterations == 0:

0 commit comments

Comments
 (0)