##// END OF EJS Templates
cleanup Client.close...
MinRK -
Show More
@@ -599,7 +599,6 b' class Client(HasTraits):'
599 self._connected=True
599 self._connected=True
600
600
601 def connect_socket(s, url):
601 def connect_socket(s, url):
602 # url = util.disambiguate_url(url, self._config['location'])
603 if self._ssh:
602 if self._ssh:
604 return tunnel.tunnel_connection(s, url, sshserver, **ssh_kwargs)
603 return tunnel.tunnel_connection(s, url, sshserver, **ssh_kwargs)
605 else:
604 else:
@@ -956,14 +955,23 b' class Client(HasTraits):'
956 view.activate(suffix)
955 view.activate(suffix)
957 return view
956 return view
958
957
959 def close(self):
958 def close(self, linger=None):
959 """Close my zmq Sockets
960
961 If `linger`, set the zmq LINGER socket option,
962 which allows discarding of messages.
963 """
960 if self._closed:
964 if self._closed:
961 return
965 return
962 self.stop_spin_thread()
966 self.stop_spin_thread()
963 snames = filter(lambda n: n.endswith('socket'), dir(self))
967 snames = [ trait for trait in self.trait_names() if trait.endswith("socket") ]
964 for socket in map(lambda name: getattr(self, name), snames):
968 for name in snames:
965 if isinstance(socket, zmq.Socket) and not socket.closed:
969 socket = getattr(self, name)
966 socket.close()
970 if socket is not None and not socket.closed:
971 if linger is not None:
972 socket.close(linger=linger)
973 else:
974 socket.close()
967 self._closed = True
975 self._closed = True
968
976
969 def _spin_every(self, interval=1):
977 def _spin_every(self, interval=1):
General Comments 0
You need to be logged in to leave comments. Login now