Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(security): add sleep to container wait loop (#12869)

Nelson Spence48cd85e47e7f
diff --git a/openhands/security/invariant/analyzer.py b/openhands/security/invariant/analyzer.py
index bba78e4ace..a9548857c6 100644
--- a/openhands/security/invariant/analyzer.py
+++ b/openhands/security/invariant/analyzer.py
@@ -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']