1616from zmq .eventloop .zmqstream import ZMQStream
1717
1818from IPython .core .application import (
19- BaseIPythonApplication , base_flags , base_aliases , catch_config_error
19+ BaseIPythonApplication , base_flags , base_aliases , catch_config_error
2020)
2121from IPython .core .profiledir import ProfileDir
2222from IPython .core .shellapp import (
23- InteractiveShellApp , shell_flags , shell_aliases
23+ InteractiveShellApp , shell_flags , shell_aliases
2424)
2525from IPython .utils import io
2626from ipython_genutils .path import filefind , ensure_dir_exists
27- from traitlets import (
28- Any , Instance , Dict , Unicode , Integer , Bool , DottedObjectName , Type ,
29- )
27+ from traitlets import (Any , Instance , Dict , Unicode , Integer , Bool ,
28+ DottedObjectName , Type , default )
3029from ipython_genutils .importstring import import_item
3130from jupyter_core .paths import jupyter_runtime_dir
3231from jupyter_client import write_connection_file
3837from .ipkernel import IPythonKernel
3938from .parentpoller import ParentPollerUnix , ParentPollerWindows
4039from jupyter_client .session import (
41- Session , session_flags , session_aliases ,
40+ Session , session_flags , session_aliases ,
4241)
4342from .zmqshell import ZMQInteractiveShell
4443
@@ -112,7 +111,7 @@ class IPKernelApp(BaseIPythonApplication, InteractiveShellApp,
112111 poller = Any () # don't restrict this even though current pollers are all Threads
113112 heartbeat = Instance (Heartbeat , allow_none = True )
114113 ports = Dict ()
115-
114+
116115 subcommands = {
117116 'install' : (
118117 'ipykernel.kernelspec.InstallIPythonKernelSpecApp' ,
@@ -122,7 +121,9 @@ class IPKernelApp(BaseIPythonApplication, InteractiveShellApp,
122121
123122 # connection info:
124123 connection_dir = Unicode ()
125- def _connection_dir_default (self ):
124+
125+ @default ('connection_dir' )
126+ def _default_connection_dir (self ):
126127 return jupyter_runtime_dir ()
127128
128129 @property
@@ -132,7 +133,6 @@ def abs_connection_file(self):
132133 else :
133134 return self .connection_file
134135
135-
136136 # streams, etc.
137137 no_stdout = Bool (False , help = "redirect stdout to the null device" ).tag (config = True )
138138 no_stderr = Bool (False , help = "redirect stderr to the null device" ).tag (config = True )
@@ -153,7 +153,7 @@ def abs_connection_file(self):
153153
154154 def init_crash_handler (self ):
155155 sys .excepthook = self .excepthook
156-
156+
157157 def excepthook (self , etype , evalue , tb ):
158158 # write uncaught traceback to 'real' stderr, not zmq-forwarder
159159 traceback .print_exception (etype , evalue , tb , file = sys .__stderr__ )
@@ -241,7 +241,7 @@ def init_sockets(self):
241241 self .control_socket .linger = 1000
242242 self .control_port = self ._bind_socket (self .control_socket , self .control_port )
243243 self .log .debug ("control ROUTER Channel on port: %i" % self .control_port )
244-
244+
245245 self .init_iopub (context )
246246
247247 def init_iopub (self , context ):
@@ -253,7 +253,6 @@ def init_iopub(self, context):
253253 self .iopub_thread .start ()
254254 # backward-compat: wrap iopub socket API in background thread
255255 self .iopub_socket = self .iopub_thread .background_socket
256-
257256
258257 def init_heartbeat (self ):
259258 """start the heart beating"""
@@ -312,9 +311,9 @@ def init_io(self):
312311 if self .displayhook_class :
313312 displayhook_factory = import_item (str (self .displayhook_class ))
314313 sys .displayhook = displayhook_factory (self .session , self .iopub_socket )
315-
314+
316315 self .patch_io ()
317-
316+
318317 def patch_io (self ):
319318 """Patch important libraries that can't handle sys.stdout forwarding"""
320319 try :
@@ -388,7 +387,7 @@ def init_shell(self):
388387 self .shell = getattr (self .kernel , 'shell' , None )
389388 if self .shell :
390389 self .shell .configurables .append (self )
391-
390+
392391 def init_extensions (self ):
393392 super (IPKernelApp , self ).init_extensions ()
394393 # BEGIN HARDCODED WIDGETS HACK
@@ -434,7 +433,6 @@ def initialize(self, argv=None):
434433 def start (self ):
435434 if self .subapp is not None :
436435 return self .subapp .start ()
437-
438436 if self .poller is not None :
439437 self .poller .start ()
440438 self .kernel .start ()
0 commit comments