File tree Expand file tree Collapse file tree 1 file changed +0
-5
lines changed
Expand file tree Collapse file tree 1 file changed +0
-5
lines changed Original file line number Diff line number Diff line change @@ -40,21 +40,17 @@ def get_exposed_port(self, internal_port: int = 3_000) -> int:
4040 if process .returncode != 0 :
4141 raise DockerCommandFailedError (
4242 f'Inspect failed with output: { stderr .decode ("utf-8" )} ' )
43-
4443 # Parse the JSON output to get the port mapping
4544 try :
4645 port_mappings = json .loads (stdout .decode ('utf-8' ).strip ())
4746 port_key = f"{ internal_port } /tcp"
48-
4947 if port_key not in port_mappings or not port_mappings [port_key ]:
5048 # Wait briefly and try to restart/refresh the container
5149 time .sleep (1 )
5250 self .restart ()
5351 time .sleep (2 ) # Wait for container to be ready
54-
5552 # Try one more time after restart
5653 return self .get_exposed_port (internal_port )
57-
5854 return int (port_mappings [port_key ][0 ]['HostPort' ])
5955 except (json .JSONDecodeError , KeyError , IndexError , TypeError ) as e :
6056 raise DockerCommandFailedError (
@@ -69,6 +65,5 @@ def restart(self):
6965 stderr = subprocess .PIPE
7066 ) as process :
7167 process .communicate ()
72-
7368 if process .returncode != 0 :
7469 raise DockerCommandFailedError ('Failed to restart container' )
You can’t perform that action at this time.
0 commit comments