Show More
@@ -303,9 +303,6 b' class NotebookApp(BaseIPythonApplication):' | |||
|
303 | 303 | self.kernel_argv.append("--KernelApp.parent_appname='%s'"%self.name) |
|
304 | 304 | |
|
305 | 305 | def init_configurables(self): |
|
306 | # Don't let Qt or ZMQ swallow KeyboardInterupts. | |
|
307 | signal.signal(signal.SIGINT, signal.SIG_DFL) | |
|
308 | ||
|
309 | 306 | # force Session default to be secure |
|
310 | 307 | default_secure(self.config) |
|
311 | 308 | # Create a KernelManager and start a kernel. |
@@ -322,11 +319,9 b' class NotebookApp(BaseIPythonApplication):' | |||
|
322 | 319 | # self.log is a child of. The logging module dipatches log messages to a log |
|
323 | 320 | # and all of its ancenstors until propagate is set to False. |
|
324 | 321 | self.log.propagate = False |
|
325 | ||
|
326 | @catch_config_error | |
|
327 | def initialize(self, argv=None): | |
|
328 | super(NotebookApp, self).initialize(argv) | |
|
329 | self.init_configurables() | |
|
322 | ||
|
323 | def init_webapp(self): | |
|
324 | """initialize tornado webapp and httpserver""" | |
|
330 | 325 | self.web_app = NotebookWebApplication( |
|
331 | 326 | self, self.kernel_manager, self.notebook_manager, self.log, |
|
332 | 327 | self.webapp_settings |
@@ -339,7 +334,7 b' class NotebookApp(BaseIPythonApplication):' | |||
|
339 | 334 | ssl_options = None |
|
340 | 335 | self.web_app.password = self.password |
|
341 | 336 | self.http_server = httpserver.HTTPServer(self.web_app, ssl_options=ssl_options) |
|
342 | if ssl_options is None and not self.ip: | |
|
337 | if ssl_options is None and not self.ip and not (self.read_only and not self.password): | |
|
343 | 338 | self.log.critical('WARNING: the notebook server is listening on all IP addresses ' |
|
344 | 339 | 'but not using any encryption or authentication. This is highly ' |
|
345 | 340 | 'insecure and not recommended.') |
@@ -357,6 +352,23 b' class NotebookApp(BaseIPythonApplication):' | |||
|
357 | 352 | else: |
|
358 | 353 | self.port = port |
|
359 | 354 | break |
|
355 | ||
|
356 | @catch_config_error | |
|
357 | def initialize(self, argv=None): | |
|
358 | super(NotebookApp, self).initialize(argv) | |
|
359 | self.init_configurables() | |
|
360 | self.init_webapp() | |
|
361 | ||
|
362 | def cleanup_kernels(self): | |
|
363 | """shutdown all kernels | |
|
364 | ||
|
365 | The kernels will shutdown themselves when this process no longer exists, | |
|
366 | but explicit shutdown allows the KernelManagers to cleanup the connection files. | |
|
367 | """ | |
|
368 | self.log.info('Shutting down kernels') | |
|
369 | km = self.kernel_manager | |
|
370 | while km.kernel_ids: | |
|
371 | km.kill_kernel(km.kernel_ids[0]) | |
|
360 | 372 | |
|
361 | 373 | def start(self): |
|
362 | 374 | ip = self.ip if self.ip else '[all ip addresses on your system]' |
@@ -371,15 +383,20 b' class NotebookApp(BaseIPythonApplication):' | |||
|
371 | 383 | b = lambda : webbrowser.open("%s://%s:%i" % (proto, ip, self.port), |
|
372 | 384 | new=2) |
|
373 | 385 | threading.Thread(target=b).start() |
|
374 | ||
|
375 | ioloop.IOLoop.instance().start() | |
|
386 | try: | |
|
387 | ioloop.IOLoop.instance().start() | |
|
388 | except KeyboardInterrupt: | |
|
389 | info("Interrupted...") | |
|
390 | finally: | |
|
391 | self.cleanup_kernels() | |
|
392 | ||
|
376 | 393 | |
|
377 | 394 | #----------------------------------------------------------------------------- |
|
378 | 395 | # Main entry point |
|
379 | 396 | #----------------------------------------------------------------------------- |
|
380 | 397 | |
|
381 | 398 | def launch_new_instance(): |
|
382 | app = NotebookApp() | |
|
399 | app = NotebookApp.instance() | |
|
383 | 400 | app.initialize() |
|
384 | 401 | app.start() |
|
385 | 402 |
General Comments 0
You need to be logged in to leave comments.
Login now