Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ansys/dpf/core/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,22 @@ def start_local_server(

server = None
n_attempts = 10
timeout = 10
timed_out = False
for _ in range(n_attempts):
try:
server = DpfServer(
ansys_path, ip, port, as_global=as_global,
ansys_path, ip, port, timeout=timeout, as_global=as_global,
load_operators=load_operators, docker_name=docker_name
)
break
except errors.InvalidPortError: # allow socket in use errors
port += 1
except TimeoutError:
if timed_out:
break
timeout *= 2.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a just a few attempts this timeout would grow quite large. Perhaps consider:

Suggested change
timeout *= 2.
timeout += 10.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akaszynski in the current implementation, the time out is only increased once

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it fails for something other than a TimeoutError, it does not go through timeout *= 2, and it can only go through it once. The thing is I did not want to make an assumption on the absolute timeout value given in input (once timeout comes from the calling function) so doubling made more sense than adding ten something.

timed_out = True

if server is None:
raise OSError(
Expand Down