Skip to content

Commit 4da1198

Browse files
committed
ensure exception is not leaked
1 parent 631c410 commit 4da1198

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

packages/pytest-simcore/src/pytest_simcore/helpers/playwright.py

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ def on_framereceived(payload: str | bytes) -> None:
137137
ctx.logger.debug("⬆️ Frame received: %s", payload)
138138

139139
def on_close(_: WebSocket) -> None:
140-
ctx.logger.warning(
141-
"⚠️ WebSocket closed. Attempting to reconnect..."
142-
)
140+
ctx.logger.warning("⚠️ WebSocket closed. Attempting to reconnect...")
143141
self._attempt_reconnect(ctx.logger)
144142

145143
def on_socketerror(error_msg: str) -> None:
@@ -320,9 +318,9 @@ def __call__(self, message: str) -> bool:
320318
new_progress
321319
!= self._current_progress[node_progress_event.progress_type]
322320
):
323-
self._current_progress[
324-
node_progress_event.progress_type
325-
] = new_progress
321+
self._current_progress[node_progress_event.progress_type] = (
322+
new_progress
323+
)
326324

327325
self.logger.info(
328326
"Current startup progress [expected number of node-progress-types=%d]: %s",
@@ -343,29 +341,30 @@ def __call__(self, message: str) -> bool:
343341
url = (
344342
f"https://{self.node_id}.services.{self.get_partial_product_url()}"
345343
)
346-
response = self.api_request_context.get(url, timeout=1000)
347-
level = logging.DEBUG
348-
if (response.status >= 400) and (response.status not in (502, 503)):
349-
level = logging.ERROR
350-
self.logger.log(
351-
level,
352-
"Querying service endpoint in case we missed some websocket messages. Url: %s Response: '%s' TIP: %s",
353-
url,
354-
f"{response.status}: {response.text()}",
355-
(
356-
"We are emulating the frontend; a 5XX response is acceptable if the service is not yet ready."
357-
),
358-
)
344+
with contextlib.suppress(PlaywrightTimeoutError):
345+
response = self.api_request_context.get(url, timeout=1000)
346+
level = logging.DEBUG
347+
if (response.status >= 400) and (response.status not in (502, 503)):
348+
level = logging.ERROR
349+
self.logger.log(
350+
level,
351+
"Querying service endpoint in case we missed some websocket messages. Url: %s Response: '%s' TIP: %s",
352+
url,
353+
f"{response.status}: {response.text()}",
354+
(
355+
"We are emulating the frontend; a 5XX response is acceptable if the service is not yet ready."
356+
),
357+
)
359358

360-
if response.status <= 400:
361-
# NOTE: If the response status is less than 400, it means that the backend is ready (There are some services that respond with a 3XX)
362-
if self.got_expected_node_progress_types():
363-
self.logger.warning(
364-
"⚠️ Progress bar didn't receive 100 percent but service is already running: %s. TIP: we missed some websocket messages! ⚠️", # https://github.com/ITISFoundation/osparc-simcore/issues/6449
365-
self.get_current_progress(),
366-
)
367-
return True
368-
self._last_poll_timestamp = datetime.now(UTC)
359+
if response.status <= 400:
360+
# NOTE: If the response status is less than 400, it means that the backend is ready (There are some services that respond with a 3XX)
361+
if self.got_expected_node_progress_types():
362+
self.logger.warning(
363+
"⚠️ Progress bar didn't receive 100 percent but service is already running: %s. TIP: we missed some websocket messages! ⚠️", # https://github.com/ITISFoundation/osparc-simcore/issues/6449
364+
self.get_current_progress(),
365+
)
366+
return True
367+
self._last_poll_timestamp = datetime.now(UTC)
369368

370369
return False
371370

0 commit comments

Comments
 (0)