-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #717 from vidartf/fix-async-restarter
Improve restarter logic
- Loading branch information
Showing
5 changed files
with
390 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""Test kernel for signalling subprocesses""" | ||
# Copyright (c) Jupyter Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
import os | ||
import time | ||
|
||
from ipykernel.displayhook import ZMQDisplayHook | ||
from ipykernel.kernelapp import IPKernelApp | ||
from ipykernel.kernelbase import Kernel | ||
|
||
|
||
class ProblemTestKernel(Kernel): | ||
"""Kernel for testing kernel problems""" | ||
|
||
implementation = "problemtest" | ||
implementation_version = "0.0" | ||
banner = "" | ||
|
||
|
||
class ProblemTestApp(IPKernelApp): | ||
kernel_class = ProblemTestKernel | ||
|
||
def init_io(self): | ||
# Overridden to disable stdout/stderr capture | ||
self.displayhook = ZMQDisplayHook(self.session, self.iopub_socket) | ||
|
||
def init_sockets(self): | ||
if os.environ.get("FAIL_ON_START") == "1": | ||
# Simulates e.g. a port binding issue (Adress already in use) | ||
raise RuntimeError("Failed for testing purposes") | ||
return super().init_sockets() | ||
|
||
|
||
if __name__ == "__main__": | ||
# make startup artificially slow, | ||
# so that we exercise client logic for slow-starting kernels | ||
startup_delay = int(os.environ.get("STARTUP_DELAY", "2")) | ||
time.sleep(startup_delay) | ||
ProblemTestApp.launch_instance() |
Oops, something went wrong.