Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make unit tests backwards compatible without pending kernels #669

Merged
merged 8 commits into from
Jan 24, 2022
Prev Previous commit
Next Next commit
make kernel shutdown in unit tests aggressive
Zsailer committed Jan 24, 2022
commit 899fa224495a8f581769730817328549f5180aef
19 changes: 15 additions & 4 deletions jupyter_server/pytest_plugin.py
Original file line number Diff line number Diff line change
@@ -476,6 +476,20 @@ def jp_cleanup_subprocesses(jp_serverapp):
async def _():
terminal_cleanup = jp_serverapp.web_app.settings["terminal_manager"].terminate_all
kernel_cleanup = jp_serverapp.kernel_manager.shutdown_all

async def kernel_cleanup_steps():
# Try a graceful shutdown with a timeout
try:
await asyncio.wait_for(kernel_cleanup(), timeout=15.0)
except asyncio.TimeoutError:
# Now force a shutdown
try:
await asyncio.wait_for(kernel_cleanup(now=True), timeout=15.0)
except asyncio.TimeoutError:
print(Exception("Kernel never shutdown!"))
except Exception as e:
print(e)

if asyncio.iscoroutinefunction(terminal_cleanup):
try:
await terminal_cleanup()
@@ -487,10 +501,7 @@ async def _():
except Exception as e:
print(e)
if asyncio.iscoroutinefunction(kernel_cleanup):
try:
await kernel_cleanup()
except Exception as e:
print(e)
await kernel_cleanup_steps()
else:
try:
kernel_cleanup()