remove Spawner.fromJSON

load state on `__init__` instead

Makes more sense now that state can persist
across server instances (e.g. docker container_id)
This commit is contained in:
MinRK
2014-10-10 12:28:27 -07:00
parent d8ef6d59c1
commit a8548164cd
3 changed files with 64 additions and 36 deletions

View File

@@ -305,13 +305,17 @@ class User(Base):
api_token = self.new_api_token()
db.add(api_token)
db.commit()
spawner = self.spawner = spawner_class(
config=config,
user=self,
hub=hub,
api_token=api_token.token,
)
# we are starting a new server, make sure it doesn't restore state
spawner.clear_state()
yield spawner.start()
spawner.start_polling()
@@ -335,6 +339,7 @@ class User(Base):
status = yield self.spawner.poll()
if status is None:
yield self.spawner.stop()
self.spawner.clear_state()
self.state = self.spawner.get_state()
self.last_activity = datetime.utcnow()
self.server = None