restore user.running property

it was made a method for handing named_servers,
but that made things way more complicated and replaced a boolean flag with a callable,
which would behave unexpectedly but without error if a boolean flag was expected.

Spawners have properties for dealing with this now, so use spawners

Restore `user.running` as an alias for `user.spawner.ready`
This commit is contained in:
Min RK
2017-08-02 14:20:56 +02:00
parent 210d7e59fd
commit 684afed3f1
13 changed files with 57 additions and 49 deletions

View File

@@ -199,6 +199,7 @@ class User(HasTraits):
hub=self.settings.get('hub'),
authenticator=self.authenticator,
config=self.settings.get('config'),
proxy_spec=url_path_join(self.proxy_spec, name, '/'),
)
# update with kwargs. Mainly for testing.
spawn_kwargs.update(kwargs)
@@ -231,16 +232,15 @@ class User(HasTraits):
def __repr__(self):
return repr(self.orm_user)
def running(self, name):
"""property for whether a user has a running server"""
if name not in self.spawners:
return False
spawner = self.spawners[name]
if spawner._spawn_pending or spawner._stop_pending or spawner._proxy_pending:
return False # server is not running if spawn or stop is still pending
if spawner.server is None:
return False
return True
@property
def running(self):
"""property for whether the user's default server is running"""
return self.spawner.ready
@property
def active(self):
"""True if any server is active"""
return any(s.active for s in self.spawners.values())
@property
def server(self):
@@ -251,11 +251,13 @@ class User(HasTraits):
"""My name, escaped for use in URLs, cookies, etc."""
return quote(self.name, safe='@')
def proxy_spec(self, name=''):
@property
def proxy_spec(self):
"""The proxy routespec for my default server"""
if self.settings.get('subdomain_host'):
return url_path_join(self.domain, self.base_url, name, '/')
return url_path_join(self.domain, self.base_url, '/')
else:
return url_path_join(self.base_url, name, '/')
return url_path_join(self.base_url, '/')
@property
def domain(self):