Show More
@@ -489,7 +489,12 b' class Client(HasTraits):' | |||||
489 | } |
|
489 | } | |
490 | self._queue_handlers = {'execute_reply' : self._handle_execute_reply, |
|
490 | self._queue_handlers = {'execute_reply' : self._handle_execute_reply, | |
491 | 'apply_reply' : self._handle_apply_reply} |
|
491 | 'apply_reply' : self._handle_apply_reply} | |
492 | self._connect(sshserver, ssh_kwargs, timeout) |
|
492 | ||
|
493 | try: | |||
|
494 | self._connect(sshserver, ssh_kwargs, timeout) | |||
|
495 | except: | |||
|
496 | self.close(linger=0) | |||
|
497 | raise | |||
493 |
|
498 | |||
494 | # last step: setup magics, if we are in IPython: |
|
499 | # last step: setup magics, if we are in IPython: | |
495 |
|
500 | |||
@@ -593,7 +598,6 b' class Client(HasTraits):' | |||||
593 | self._connected=True |
|
598 | self._connected=True | |
594 |
|
599 | |||
595 | def connect_socket(s, url): |
|
600 | def connect_socket(s, url): | |
596 | # url = util.disambiguate_url(url, self._config['location']) |
|
|||
597 | if self._ssh: |
|
601 | if self._ssh: | |
598 | return tunnel.tunnel_connection(s, url, sshserver, **ssh_kwargs) |
|
602 | return tunnel.tunnel_connection(s, url, sshserver, **ssh_kwargs) | |
599 | else: |
|
603 | else: | |
@@ -950,14 +954,23 b' class Client(HasTraits):' | |||||
950 | view.activate(suffix) |
|
954 | view.activate(suffix) | |
951 | return view |
|
955 | return view | |
952 |
|
956 | |||
953 | def close(self): |
|
957 | def close(self, linger=None): | |
|
958 | """Close my zmq Sockets | |||
|
959 | ||||
|
960 | If `linger`, set the zmq LINGER socket option, | |||
|
961 | which allows discarding of messages. | |||
|
962 | """ | |||
954 | if self._closed: |
|
963 | if self._closed: | |
955 | return |
|
964 | return | |
956 | self.stop_spin_thread() |
|
965 | self.stop_spin_thread() | |
957 | snames = filter(lambda n: n.endswith('socket'), dir(self)) |
|
966 | snames = [ trait for trait in self.trait_names() if trait.endswith("socket") ] | |
958 | for socket in map(lambda name: getattr(self, name), snames): |
|
967 | for name in snames: | |
959 | if isinstance(socket, zmq.Socket) and not socket.closed: |
|
968 | socket = getattr(self, name) | |
960 |
socket.close |
|
969 | if socket is not None and not socket.closed: | |
|
970 | if linger is not None: | |||
|
971 | socket.close(linger=linger) | |||
|
972 | else: | |||
|
973 | socket.close() | |||
961 | self._closed = True |
|
974 | self._closed = True | |
962 |
|
975 | |||
963 | def _spin_every(self, interval=1): |
|
976 | def _spin_every(self, interval=1): |
General Comments 0
You need to be logged in to leave comments.
Login now