Browse Source

[FIX] sleep time to load correct status

Gogs 7 years ago
parent
commit
c95c7e34a9
1 changed files with 10 additions and 0 deletions
  1. 10 0
      api/utils/docker_api.py

+ 10 - 0
api/utils/docker_api.py

@@ -3,6 +3,7 @@ from __future__ import unicode_literals
 from django.conf import settings
 from docker import DockerClient
 from docker.errors import DockerException, NotFound, APIError
+import time
 
 '''
 '''
@@ -67,6 +68,9 @@ def start_container(id=None):
     try:
         container = client.containers.get(id)
         container.start()
+
+        time.sleep(1)
+
         container.reload()
 
         return {
@@ -96,6 +100,9 @@ def restart_container(id=None):
     try:
         container = client.containers.get(id)
         container.restart()
+
+        time.sleep(1)
+
         container.reload()
 
         return {
@@ -125,6 +132,9 @@ def stop_container(id=None):
     try:
         container = client.containers.get(id)
         container.stop()
+
+        time.sleep(1)
+
         container.reload()
 
         return {