##// END OF EJS Templates
Cleaned up KernelManager.__init__ for better traits usage.
Brian Granger -
Show More
@@ -425,10 +425,10 b' class KernelManager(HasTraits):'
425 frontend.
425 frontend.
426 """
426 """
427 # The PyZMQ Context to use for communication with the kernel.
427 # The PyZMQ Context to use for communication with the kernel.
428 context = Instance(zmq.Context)
428 context = Instance(zmq.Context,(),{})
429
429
430 # The Session to use for communication with the kernel.
430 # The Session to use for communication with the kernel.
431 session = Instance(Session)
431 session = Instance(Session,(),{})
432
432
433 # The kernel process with which the KernelManager is communicating.
433 # The kernel process with which the KernelManager is communicating.
434 kernel = Instance(Popen)
434 kernel = Instance(Popen)
@@ -439,22 +439,15 b' class KernelManager(HasTraits):'
439 rep_channel_class = Type(RepSocketChannel)
439 rep_channel_class = Type(RepSocketChannel)
440
440
441 # Protected traits.
441 # Protected traits.
442 _xreq_address = TCPAddress
442 xreq_address = TCPAddress((LOCALHOST, 0))
443 _sub_address = TCPAddress
443 sub_address = TCPAddress((LOCALHOST, 0))
444 _rep_address = TCPAddress
444 rep_address = TCPAddress((LOCALHOST, 0))
445 _xreq_channel = Any
445 _xreq_channel = Any
446 _sub_channel = Any
446 _sub_channel = Any
447 _rep_channel = Any
447 _rep_channel = Any
448
448
449 def __init__(self, xreq_address=None, sub_address=None, rep_address=None,
449 def __init__(self, **kwargs):
450 context=None, session=None):
450 super(KernelManager, self).__init__(**kwargs)
451 super(KernelManager, self).__init__()
452 self._xreq_address = (LOCALHOST, 0) if xreq_address is None else xreq_address
453 self._sub_address = (LOCALHOST, 0) if sub_address is None else sub_address
454 self._rep_address = (LOCALHOST, 0) if rep_address is None else rep_address
455 self.context = zmq.Context() if context is None else context
456 self.session = Session() if session is None else session
457 super(KernelManager, self).__init__()
458
451
459 #--------------------------------- -----------------------------------------
452 #--------------------------------- -----------------------------------------
460 # Channel management methods:
453 # Channel management methods:
@@ -507,9 +500,9 b' class KernelManager(HasTraits):'
507
500
508 self.kernel, xrep, pub, req = launch_kernel(
501 self.kernel, xrep, pub, req = launch_kernel(
509 xrep_port=xreq[1], pub_port=sub[1], req_port=rep[1])
502 xrep_port=xreq[1], pub_port=sub[1], req_port=rep[1])
510 self._xreq_address = (LOCALHOST, xrep)
503 self.xreq_address = (LOCALHOST, xrep)
511 self._sub_address = (LOCALHOST, pub)
504 self.sub_address = (LOCALHOST, pub)
512 self._rep_address = (LOCALHOST, req)
505 self.rep_address = (LOCALHOST, req)
513
506
514 @property
507 @property
515 def has_kernel(self):
508 def has_kernel(self):
@@ -576,16 +569,3 b' class KernelManager(HasTraits):'
576 self.session,
569 self.session,
577 self.rep_address)
570 self.rep_address)
578 return self._rep_channel
571 return self._rep_channel
579
580 @property
581 def xreq_address(self):
582 return self._xreq_address
583
584 @property
585 def sub_address(self):
586 return self._sub_address
587
588 @property
589 def rep_address(self):
590 return self._rep_address
591
General Comments 0
You need to be logged in to leave comments. Login now