Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

fix /hub/stats #204

Merged
merged 2 commits into from Jun 30, 2017
Jump to file or symbol
Failed to load files and symbols.
+8 −3
Split
View
@@ -45,7 +45,6 @@ def __init__(self, **kwargs):
ContainerHandler.__init__(self, **kwargs)
EmailNotificator.__init__(self)
-
# We override the executor here to increase the number of threads
@property
def executor(self):
@@ -55,6 +54,9 @@ def executor(self):
cls._executor = ThreadPoolExecutor(20)
return cls._executor
+ @staticmethod
+ def get_global_client():
+ return CustomDockerSpawner._client
def _docker(self, method, *args, **kwargs):
"""wrapper for calling docker methods
@@ -38,5 +38,8 @@ def get(self, *args, **kwargs):
@gen.coroutine
def get_running_container_count(self):
"""Get the number of currently running containers."""
- return len(Client().containers(
- filters={'status': self.container_statuses['running']}))
+ client = self.spawner_class.get_global_client()
+ if client is None:
+ # None means that there were no launches
+ return 0
+ return len(client.containers(filters={'status': self.container_statuses['running']}))