URI: 
       tclose interfaces on shutdown - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 58c817f81aba5da109113f26d4b6d80c492b8f4d
   DIR parent e702b3312b071579c1f77e9c107801fd52cce9be
  HTML Author: ThomasV <thomasv@gitorious>
       Date:   Tue, 29 Jul 2014 12:13:21 +0200
       
       close interfaces on shutdown
       
       Diffstat:
         M electrum                            |       2 +-
         M lib/interface.py                    |       4 ++--
         M lib/network.py                      |       7 ++++++-
         M lib/network_proxy.py                |       7 +++----
       
       4 files changed, 12 insertions(+), 8 deletions(-)
       ---
   DIR diff --git a/electrum b/electrum
       t@@ -209,7 +209,7 @@ if __name__ == '__main__':
        
                # we use daemon threads, their termination is enforced.
                # this sleep command gives them time to terminate cleanly.
       -        time.sleep(0.2)
       +        time.sleep(0.3)
                sys.exit(0)
        
            if cmd == 'daemon':
   DIR diff --git a/lib/interface.py b/lib/interface.py
       t@@ -311,9 +311,9 @@ class TcpInterface(threading.Thread):
                        break
                    self.process_response(response)
        
       -        print_error("exit interface", self.server)
                self.change_status()
       -        
       +        print_error("closing connection:", self.server)
       +
            def change_status(self):
                # print_error( "change status", self.server, self.is_connected)
                self.response_queue.put((self, None))
   DIR diff --git a/lib/network.py b/lib/network.py
       t@@ -368,7 +368,7 @@ class Network(threading.Thread):
            def run(self):
                while self.is_running():
                    try:
       -                i, response = self.queue.get(0.1) #timeout = 30 if self.interfaces else 3)
       +                i, response = self.queue.get(timeout=0.1) #timeout = 30 if self.interfaces else 3)
                    except Queue.Empty:
                        if len(self.interfaces) < self.num_server:
                            self.start_random_interface()
       t@@ -404,6 +404,10 @@ class Network(threading.Thread):
                    if not self.interface.is_connected and self.config.get('auto_cycle'):
                        self.switch_to_random_interface()
        
       +        print_error("Network: Stopping interfaces")
       +        for i in self.interfaces.values():
       +            i.stop()
       +
        
            def on_header(self, i, r):
                result = r.get('result')
       t@@ -440,6 +444,7 @@ class Network(threading.Thread):
                self.response_queue.put(r)
        
            def stop(self):
       +        print_error("stopping network")
                with self.lock:
                    self.running = False
        
   DIR diff --git a/lib/network_proxy.py b/lib/network_proxy.py
       t@@ -86,8 +86,9 @@ class NetworkProxy(threading.Thread):
                        break
                    self.process(response)
        
       -        print_error("NetworkProxy thread terminating")
       -        self.stop()
       +        if self.network:
       +            self.network.stop()
       +        print_error("NetworkProxy: terminating")
        
            def process(self, response):
                if self.debug: 
       t@@ -215,8 +216,6 @@ class NetworkProxy(threading.Thread):
        
            def stop(self):
                self.running = False
       -        if self.network:
       -            self.network.stop()
        
            def stop_daemon(self):
                return self.send([('daemon.stop',[])], None)