Correct issue with args and thread in WebUI for the Docker plugin (issue #654)

This commit is contained in:
nicolargo 2015-08-22 23:02:18 +02:00
parent 2e53ec7850
commit 3d3f6b09d0
2 changed files with 3 additions and 11 deletions

View File

@ -51,3 +51,4 @@ class GlancesWebServer(object):
def end(self):
"""End of the Web server."""
self.web.end()
self.stats.end()

View File

@ -28,7 +28,6 @@ import time
from glances.core.glances_logging import logger
from glances.core.glances_timer import getTimeSinceLastUpdate
from glances.plugins.glances_plugin import GlancesPlugin
from glances.core.glances_timer import Timer
# Docker-py library (optional and Linux-only)
# https://github.com/docker/docker-py
@ -202,7 +201,7 @@ class Plugin(GlancesPlugin):
# Thread did not exist in the internal dict
# Create it and add it to the internal dict
logger.debug("{} plugin - Create thread for container {}".format(self.plugin_name, container['Id'][:12]))
t = ThreadDockerGrabber(self.docker_client, container['Id'], self.args.time)
t = ThreadDockerGrabber(self.docker_client, container['Id'])
self.thread_list[container['Id']] = t
t.start()
@ -452,14 +451,12 @@ class ThreadDockerGrabber(threading.Thread):
stats is a dict
"""
def __init__(self, docker_client, container_id, refresh_time=3):
def __init__(self, docker_client, container_id):
"""Init the class:
docker_client: instance of Docker-py client
container_id: Id of the container"""
logger.debug("docker plugin - Create thread for container {}".format(container_id[:12]))
super(ThreadDockerGrabber, self).__init__()
# Refresh time for sub thread
self._refresh_time = refresh_time
# Event needed to stop properly the thread
self._stop = threading.Event()
# The docker-py return stats as a stream
@ -474,12 +471,6 @@ class ThreadDockerGrabber(threading.Thread):
for i in self._stats_stream:
self._stats = i
# countdown = Timer(self._refresh_time)
# while not countdown.finished() and not is_stopped:
# is_stopped = self.stopped()
# time.sleep(0.1)
# if is_stopped:
# break
time.sleep(0.1)
if self.stopped():
break