This commit is contained in:
kshitija08
2018-10-04 20:29:30 +05:30
parent 7409ccad66
commit ae51870db5
2 changed files with 4 additions and 3 deletions

View File

@@ -33,7 +33,7 @@ from ..metrics import (
SERVER_SPAWN_DURATION_SECONDS, ServerSpawnStatus,
PROXY_ADD_DURATION_SECONDS, ProxyAddStatus,
SERVER_POLL_DURATION_SECONDS, ServerPollStatus,
RUNNING_SERVERS, TOTAL_USERS
RUNNING_SERVERS
)
# pattern for the authentication token header
@@ -740,7 +740,6 @@ class BaseHandler(RequestHandler):
spawner._proxy_pending = True
try:
await self.proxy.add_user(user, server_name)
TOTAL_USERS.inc()
PROXY_ADD_DURATION_SECONDS.labels(
status='success'
@@ -872,7 +871,6 @@ class BaseHandler(RequestHandler):
)
await self.proxy.delete_user(user, server_name)
await user.stop(server_name)
TOTAL_USERS.dec()
async def stop_single_user(self, user, server_name=''):
if server_name not in user.spawners:

View File

@@ -17,6 +17,7 @@ from ._version import _check_version, __version__
from .objects import Server
from .spawner import LocalProcessSpawner
from .crypto import encrypt, decrypt, CryptKeeper, EncryptionUnavailable, InvalidToken
from .metrics import TOTAL_USERS
class UserDict(dict):
"""Like defaultdict, but for users
@@ -39,6 +40,7 @@ class UserDict(dict):
"""Add a user to the UserDict"""
if orm_user.id not in self:
self[orm_user.id] = self.from_orm(orm_user)
TOTAL_USERS.inc()
return self[orm_user.id]
def __contains__(self, key):
@@ -93,6 +95,7 @@ class UserDict(dict):
self.db.delete(user)
self.db.commit()
# delete from dict after commit
TOTAL_USERS.dec()
del self[user_id]
def count_active_users(self):