avoid stopping event loop in app fixture

let pytest-asyncio do it
This commit is contained in:
Min RK
2025-10-02 14:54:16 -07:00
parent 642475f844
commit 11bc5c325a
2 changed files with 8 additions and 0 deletions

View File

@@ -3887,6 +3887,10 @@ class JupyterHub(Application):
tasks = [t for t in asyncio.all_tasks()] tasks = [t for t in asyncio.all_tasks()]
for t in tasks: for t in tasks:
self.log.debug("Task status: %s", t) self.log.debug("Task status: %s", t)
self._stop_event_loop()
def _stop_event_loop(self):
"""In a method to allow tests to not do this"""
asyncio.get_event_loop().stop() asyncio.get_event_loop().stop()
def stop(self): def stop(self):

View File

@@ -382,6 +382,10 @@ class MockHub(JupyterHub):
super().stop() super().stop()
self.db_file.close() self.db_file.close()
def _stop_event_loop(self):
# leave it to pytest-asyncio to stop the loop
pass
async def login_user(self, name): async def login_user(self, name):
"""Login a user by name, returning her cookies.""" """Login a user by name, returning her cookies."""
base_url = public_url(self) base_url = public_url(self)