80
80
81
81
import ansys .fluent .core as pyfluent
82
82
from ansys .fluent .core .docker .docker_compose import ComposeBasedLauncher
83
+ from ansys .fluent .core .launcher .error_handler import (
84
+ LaunchFluentError ,
85
+ )
83
86
from ansys .fluent .core .launcher .launcher_utils import is_compose
84
87
from ansys .fluent .core .session import _parse_server_info_file
85
88
from ansys .fluent .core .utils .deprecate import all_deprecators
@@ -155,7 +158,6 @@ def configure_container_dict(
155
158
args : List [str ],
156
159
mount_source : str | Path | None = None ,
157
160
mount_target : str | Path | None = None ,
158
- timeout : int | None = None ,
159
161
port : int | None = None ,
160
162
license_server : str | None = None ,
161
163
container_server_info_file : str | Path | None = None ,
@@ -179,8 +181,6 @@ def configure_container_dict(
179
181
mount_target : str | Path, optional
180
182
Path inside the container where ``mount_source`` will be mounted. This will be the working directory path
181
183
visible to the Fluent process running inside the container.
182
- timeout : int, optional
183
- Time limit for the Fluent container to start, in seconds. By default, 60 seconds.
184
184
port : int, optional
185
185
Port for Fluent container to use.
186
186
license_server : str, optional
@@ -206,7 +206,6 @@ def configure_container_dict(
206
206
-------
207
207
fluent_image : str
208
208
container_dict : dict
209
- timeout : int
210
209
port : int
211
210
host_server_info_file : Path
212
211
remove_server_info_file: bool
@@ -230,8 +229,6 @@ def configure_container_dict(
230
229
231
230
See also :func:`start_fluent_container`.
232
231
"""
233
- if timeout is None :
234
- timeout = int (os .getenv ("PYFLUENT_FLUENT_LAUNCH_TIMEOUT" , "60" ))
235
232
236
233
logger .debug (f"container_dict before processing:\n { dict_to_str (container_dict )} " )
237
234
@@ -446,23 +443,22 @@ def configure_container_dict(
446
443
container_dict ["mount_target" ] = mount_target
447
444
448
445
logger .debug (
449
- f"Fluent container timeout: { timeout } , container_grpc_port: { container_grpc_port } , "
446
+ f"Fluent container container_grpc_port: { container_grpc_port } , "
450
447
f"host_server_info_file: '{ host_server_info_file } ', "
451
448
f"remove_server_info_file: { remove_server_info_file } "
452
449
)
453
450
logger .debug (f"container_dict after processing:\n { dict_to_str (container_dict )} " )
454
451
455
452
return (
456
453
container_dict ,
457
- timeout ,
458
454
container_grpc_port ,
459
455
host_server_info_file ,
460
456
remove_server_info_file ,
461
457
)
462
458
463
459
464
460
def start_fluent_container (
465
- args : List [str ], container_dict : dict | None = None
461
+ args : List [str ], container_dict : dict | None = None , start_timeout : int = 60
466
462
) -> tuple [int , str , Any ]:
467
463
"""Start a Fluent container.
468
464
@@ -472,6 +468,9 @@ def start_fluent_container(
472
468
List of Fluent launch arguments.
473
469
container_dict : dict, optional
474
470
Dictionary with Docker container configuration.
471
+ start_timeout : int, optional
472
+ Timeout in seconds for the container to start. If not specified, it defaults to 60
473
+ seconds.
475
474
476
475
Returns
477
476
-------
@@ -500,11 +499,11 @@ def start_fluent_container(
500
499
501
500
(
502
501
config_dict ,
503
- timeout ,
504
502
port ,
505
503
host_server_info_file ,
506
504
remove_server_info_file ,
507
505
) = container_vars
506
+ launch_string = " " .join (config_dict ["command" ])
508
507
509
508
try :
510
509
if is_compose ():
@@ -538,20 +537,26 @@ def start_fluent_container(
538
537
config_dict .pop ("fluent_image" ), ** config_dict
539
538
)
540
539
541
- logger .debug (f"Waiting for container for up to { timeout } seconds..." )
540
+ logger .debug (
541
+ f"Waiting for Fluent container for up to { start_timeout } seconds..."
542
+ )
542
543
543
544
success = timeout_loop (
544
- lambda : host_server_info_file .stat ().st_mtime > last_mtime , timeout
545
+ lambda : host_server_info_file .stat ().st_mtime > last_mtime ,
546
+ start_timeout ,
545
547
)
546
548
547
549
if not success :
548
550
raise TimeoutError (
549
- f"Fluent container launch has timed out after { timeout } seconds. Container will need to be stopped manually."
551
+ f"Fluent container launch has timed out after { start_timeout } seconds. Container will need to be stopped manually."
550
552
)
551
553
else :
552
554
_ , _ , password = _parse_server_info_file (str (host_server_info_file ))
553
555
554
556
return port , password , container
557
+ except Exception as ex :
558
+ logger .error (f"Exception caught - { type (ex ).__name__ } : { ex } " )
559
+ raise LaunchFluentError (launch_string ) from ex
555
560
finally :
556
561
if remove_server_info_file and host_server_info_file .exists ():
557
562
host_server_info_file .unlink ()
0 commit comments