Skip to content

Commit 3a53d22

Browse files
krisctlPrabhakar Kumar
authored andcommitted
Fixes race condition in tests during file read operations.
1 parent bc3cbb0 commit 3a53d22

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/test_devel.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020-2022 The MathWorks, Inc.
1+
# Copyright (c) 2020-2023 The MathWorks, Inc.
22

33
import os
44
import socket
@@ -232,6 +232,9 @@ def get_matlab_port_from_ready_file(matlab_ready_file):
232232
try:
233233
with open(matlab_ready_file) as f:
234234
return int(f.read())
235-
except FileNotFoundError:
235+
# Retry in the event that matlab_ready_file isn't created yet or
236+
# it has been created but the matlab_port information is not yet
237+
# written into the file which throws ValueError while converting to int.
238+
except (FileNotFoundError, ValueError):
236239
time.sleep(HALF_SECOND_DELAY)
237240
continue

0 commit comments

Comments
 (0)