mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
fix(security): add sleep to container wait loop (#12869)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
# Unless you are working on deprecation, please avoid extending this legacy file and consult the V1 codepaths above.
|
||||
# Tag: Legacy-V0
|
||||
import re
|
||||
import time
|
||||
import uuid
|
||||
from typing import Any
|
||||
|
||||
@@ -71,15 +72,16 @@ class InvariantAnalyzer(SecurityAnalyzer):
|
||||
else:
|
||||
self.container = running_containers[0]
|
||||
|
||||
elapsed = 0
|
||||
start_time = time.time()
|
||||
while self.container.status != 'running':
|
||||
self.container = self.docker_client.containers.get(self.container_name)
|
||||
elapsed += 1
|
||||
elapsed = time.time() - start_time
|
||||
logger.debug(
|
||||
f'waiting for container to start: {elapsed}, container status: {self.container.status}'
|
||||
f'waiting for container to start: {elapsed:.1f}s, container status: {self.container.status}'
|
||||
)
|
||||
if elapsed > self.timeout:
|
||||
break
|
||||
time.sleep(0.5)
|
||||
|
||||
self.api_port = int(
|
||||
self.container.attrs['NetworkSettings']['Ports']['8000/tcp'][0]['HostPort']
|
||||
|
||||
Reference in New Issue
Block a user