mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-08 18:44:10 +00:00
service.stop is a coroutine
fixes waiting for services to stop on shutdown
This commit is contained in:
@@ -1494,7 +1494,7 @@ class JupyterHub(Application):
|
|||||||
if managed_services:
|
if managed_services:
|
||||||
self.log.info("Cleaning up %i services...", len(managed_services))
|
self.log.info("Cleaning up %i services...", len(managed_services))
|
||||||
for service in managed_services:
|
for service in managed_services:
|
||||||
service.stop()
|
await service.stop()
|
||||||
|
|
||||||
if self.cleanup_servers:
|
if self.cleanup_servers:
|
||||||
self.log.info("Cleaning up single-user servers...")
|
self.log.info("Cleaning up single-user servers...")
|
||||||
|
@@ -56,6 +56,7 @@ from ..traitlets import Command
|
|||||||
from ..spawner import LocalProcessSpawner, set_user_setuid
|
from ..spawner import LocalProcessSpawner, set_user_setuid
|
||||||
from ..utils import url_path_join
|
from ..utils import url_path_join
|
||||||
|
|
||||||
|
|
||||||
class _MockUser(HasTraits):
|
class _MockUser(HasTraits):
|
||||||
name = Unicode()
|
name = Unicode()
|
||||||
server = Instance(orm.Server, allow_none=True)
|
server = Instance(orm.Server, allow_none=True)
|
||||||
@@ -123,6 +124,7 @@ class _ServiceSpawner(LocalProcessSpawner):
|
|||||||
|
|
||||||
self.pid = self.proc.pid
|
self.pid = self.proc.pid
|
||||||
|
|
||||||
|
|
||||||
class Service(LoggingConfigurable):
|
class Service(LoggingConfigurable):
|
||||||
"""An object wrapping a service specification for Hub API consumers.
|
"""An object wrapping a service specification for Hub API consumers.
|
||||||
|
|
||||||
@@ -320,7 +322,7 @@ class Service(LoggingConfigurable):
|
|||||||
self.log.error("Service %s exited with status %i", self.name, self.proc.returncode)
|
self.log.error("Service %s exited with status %i", self.name, self.proc.returncode)
|
||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
def stop(self):
|
async def stop(self):
|
||||||
"""Stop a managed service"""
|
"""Stop a managed service"""
|
||||||
self.log.debug("Stopping service %s", self.name)
|
self.log.debug("Stopping service %s", self.name)
|
||||||
if not self.managed:
|
if not self.managed:
|
||||||
@@ -330,4 +332,4 @@ class Service(LoggingConfigurable):
|
|||||||
self.db.delete(self.orm.server)
|
self.db.delete(self.orm.server)
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
self.spawner.stop_polling()
|
self.spawner.stop_polling()
|
||||||
return self.spawner.stop()
|
return (await self.spawner.stop())
|
||||||
|
Reference in New Issue
Block a user