fix missing import and resolve class attributes

This commit is contained in:
GeorgianaElena
2018-10-02 11:58:33 +03:00
parent 425078652e
commit 67b774faca
2 changed files with 9 additions and 7 deletions

View File

@@ -32,7 +32,7 @@ from ..utils import maybe_future, url_path_join
from ..metrics import (
SERVER_SPAWN_DURATION_SECONDS, ServerSpawnStatus,
PROXY_ADD_DURATION_SECONDS, ProxyAddStatus,
SERVER_POLL_DURATION_SECONDS,
SERVER_POLL_DURATION_SECONDS, ServerPollStatus,
RUNNING_SERVERS
)
@@ -825,7 +825,7 @@ class BaseHandler(RequestHandler):
poll_start_time = time.perf_counter()
status = await spawner.poll()
SERVER_POLL_DURATION_SECONDS.labels(
status=ServerPollStatus.status_to_string(status)
status=ServerPollStatus.from_status(status)
).observe(time.perf_counter() - poll_start_time)
if status is not None:
@@ -859,7 +859,7 @@ class BaseHandler(RequestHandler):
poll_start_time = time.perf_counter()
status = await spawner.poll()
SERVER_POLL_DURATION_SECONDS.labels(
status=ServerPollStatus.status_to_string(status)
status=ServerPollStatus.from_status(status)
).observe(time.perf_counter() - poll_start_time)
@@ -1170,7 +1170,7 @@ class UserSpawnHandler(BaseHandler):
poll_start_time = time.perf_counter()
status = await spawner.poll()
SERVER_POLL_DURATION_SECONDS.labels(
status=ServerPollStatus.status_to_string(status)
status=ServerPollStatus.from_status(status)
).observe(time.perf_counter() - poll_start_time)
else:
status = 0

View File

@@ -93,10 +93,12 @@ class ServerPollStatus(Enum):
running = 'running'
stopped = 'stopped'
def status_to_string(status):
@classmethod
def from_status(cls, status):
"""Return enum string for a given poll status"""
if status is None:
return running
return stopped
return cls.running
return cls.stopped
def __str__(self):
return self.value