2525from IPython .utils import io
2626from ipython_genutils .path import filefind , ensure_dir_exists
2727from traitlets import (
28- Any , Instance , Dict , Unicode , Integer , Bool , DottedObjectName , Type ,
28+ Any , Instance , Dict , Unicode , Integer , Bool , DottedObjectName , Type , default
2929)
3030from ipython_genutils .importstring import import_item
3131from jupyter_core .paths import jupyter_runtime_dir
@@ -112,7 +112,7 @@ class IPKernelApp(BaseIPythonApplication, InteractiveShellApp,
112112 poller = Any () # don't restrict this even though current pollers are all Threads
113113 heartbeat = Instance (Heartbeat , allow_none = True )
114114 ports = Dict ()
115-
115+
116116 subcommands = {
117117 'install' : (
118118 'ipykernel.kernelspec.InstallIPythonKernelSpecApp' ,
@@ -122,7 +122,9 @@ class IPKernelApp(BaseIPythonApplication, InteractiveShellApp,
122122
123123 # connection info:
124124 connection_dir = Unicode ()
125- def _connection_dir_default (self ):
125+
126+ @default ('connection_dir' )
127+ def _default_connection_dir (self ):
126128 return jupyter_runtime_dir ()
127129
128130 @property
@@ -132,7 +134,6 @@ def abs_connection_file(self):
132134 else :
133135 return self .connection_file
134136
135-
136137 # streams, etc.
137138 no_stdout = Bool (False , help = "redirect stdout to the null device" ).tag (config = True )
138139 no_stderr = Bool (False , help = "redirect stderr to the null device" ).tag (config = True )
@@ -153,7 +154,7 @@ def abs_connection_file(self):
153154
154155 def init_crash_handler (self ):
155156 sys .excepthook = self .excepthook
156-
157+
157158 def excepthook (self , etype , evalue , tb ):
158159 # write uncaught traceback to 'real' stderr, not zmq-forwarder
159160 traceback .print_exception (etype , evalue , tb , file = sys .__stderr__ )
@@ -241,7 +242,7 @@ def init_sockets(self):
241242 self .control_socket .linger = 1000
242243 self .control_port = self ._bind_socket (self .control_socket , self .control_port )
243244 self .log .debug ("control ROUTER Channel on port: %i" % self .control_port )
244-
245+
245246 self .init_iopub (context )
246247
247248 def init_iopub (self , context ):
@@ -253,7 +254,6 @@ def init_iopub(self, context):
253254 self .iopub_thread .start ()
254255 # backward-compat: wrap iopub socket API in background thread
255256 self .iopub_socket = self .iopub_thread .background_socket
256-
257257
258258 def init_heartbeat (self ):
259259 """start the heart beating"""
@@ -312,9 +312,9 @@ def init_io(self):
312312 if self .displayhook_class :
313313 displayhook_factory = import_item (str (self .displayhook_class ))
314314 sys .displayhook = displayhook_factory (self .session , self .iopub_socket )
315-
315+
316316 self .patch_io ()
317-
317+
318318 def patch_io (self ):
319319 """Patch important libraries that can't handle sys.stdout forwarding"""
320320 try :
@@ -388,7 +388,7 @@ def init_shell(self):
388388 self .shell = getattr (self .kernel , 'shell' , None )
389389 if self .shell :
390390 self .shell .configurables .append (self )
391-
391+
392392 def init_extensions (self ):
393393 super (IPKernelApp , self ).init_extensions ()
394394 # BEGIN HARDCODED WIDGETS HACK
@@ -434,7 +434,6 @@ def initialize(self, argv=None):
434434 def start (self ):
435435 if self .subapp is not None :
436436 return self .subapp .start ()
437-
438437 if self .poller is not None :
439438 self .poller .start ()
440439 self .kernel .start ()
0 commit comments