mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
Merge pull request #7709 from SylvainCorlay/iptest
JSController cleanup: support case where no server is started
This commit is contained in:
commit
f7f802bb33
@ -396,33 +396,34 @@ class JSController(TestController):
|
|||||||
self.server_port = info['port']
|
self.server_port = info['port']
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
try:
|
if hasattr(self, 'server'):
|
||||||
self.server.terminate()
|
|
||||||
except OSError:
|
|
||||||
# already dead
|
|
||||||
pass
|
|
||||||
# wait 10s for the server to shutdown
|
|
||||||
try:
|
|
||||||
popen_wait(self.server, NOTEBOOK_SHUTDOWN_TIMEOUT)
|
|
||||||
except TimeoutExpired:
|
|
||||||
# server didn't terminate, kill it
|
|
||||||
try:
|
try:
|
||||||
print("Failed to terminate notebook server, killing it.",
|
self.server.terminate()
|
||||||
file=sys.stderr
|
|
||||||
)
|
|
||||||
self.server.kill()
|
|
||||||
except OSError:
|
except OSError:
|
||||||
# already dead
|
# already dead
|
||||||
pass
|
pass
|
||||||
# wait another 10s
|
# wait 10s for the server to shutdown
|
||||||
try:
|
try:
|
||||||
popen_wait(self.server, NOTEBOOK_SHUTDOWN_TIMEOUT)
|
popen_wait(self.server, NOTEBOOK_SHUTDOWN_TIMEOUT)
|
||||||
except TimeoutExpired:
|
except TimeoutExpired:
|
||||||
print("Notebook server still running (%s)" % self.server_info_file,
|
# server didn't terminate, kill it
|
||||||
file=sys.stderr
|
try:
|
||||||
)
|
print("Failed to terminate notebook server, killing it.",
|
||||||
|
file=sys.stderr
|
||||||
self.stream_capturer.halt()
|
)
|
||||||
|
self.server.kill()
|
||||||
|
except OSError:
|
||||||
|
# already dead
|
||||||
|
pass
|
||||||
|
# wait another 10s
|
||||||
|
try:
|
||||||
|
popen_wait(self.server, NOTEBOOK_SHUTDOWN_TIMEOUT)
|
||||||
|
except TimeoutExpired:
|
||||||
|
print("Notebook server still running (%s)" % self.server_info_file,
|
||||||
|
file=sys.stderr
|
||||||
|
)
|
||||||
|
|
||||||
|
self.stream_capturer.halt()
|
||||||
TestController.cleanup(self)
|
TestController.cleanup(self)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user