mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 14:03:02 +00:00
fix missing import and resolve class attributes
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user