URI: 
       tnetwork.pending_servers, to avoid connecting the same server multiple times - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 942d009661431b0fb6f3daa531d03cb345f8657d
   DIR parent c7694a87e7f2dc4a763a9823e77260b14a3da604
  HTML Author: thomasv <thomasv@gitorious>
       Date:   Mon, 16 Dec 2013 18:17:44 +0100
       
       network.pending_servers, to avoid connecting the same server multiple times
       
       Diffstat:
         M lib/network.py                      |      23 ++++++++++++-----------
         M lib/wallet.py                       |       2 +-
       
       2 files changed, 13 insertions(+), 12 deletions(-)
       ---
   DIR diff --git a/lib/network.py b/lib/network.py
       t@@ -58,7 +58,8 @@ class Network(threading.Thread):
                    self.default_server = pick_random_server(self.protocol)
        
                self.irc_servers = [] # returned by interface (list from irc)
       -        self.disconnected_servers = []
       +        self.pending_servers = set([])
       +        self.disconnected_servers = set([])
                self.recent_servers = self.config.get('recent_servers',[]) # successful connections
        
                self.banner = ''
       t@@ -124,7 +125,7 @@ class Network(threading.Thread):
                choice_list = []
                l = filter_protocol(self.get_servers(), self.protocol)
                for s in l:
       -            if s in self.disconnected_servers or s in self.interfaces.keys():
       +            if s in self.pending_servers or s in self.disconnected_servers or s in self.interfaces.keys():
                        continue
                    else:
                        choice_list.append(s)
       t@@ -151,7 +152,7 @@ class Network(threading.Thread):
                if server in self.interfaces.keys():
                    return
                i = interface.Interface(server, self.config)
       -        # add it only if it gets connected
       +        self.pending_servers.add(server)
                i.start(self.queue)
                return i 
        
       t@@ -171,13 +172,12 @@ class Network(threading.Thread):
                self.start_interfaces()
                threading.Thread.start(self)
                if wait:
       -            self.interface.connect_event.wait()
       -            return self.interface.is_connected
       -
       -
       -    def wait_until_connected(self):
       -        while not self.is_connected():
       -            time.sleep(1)
       +            if self.config.get('auto_cycle'): 
       +                while not self.is_connected():
       +                    time.sleep(0.1)
       +            else:
       +                self.interface.connect_event.wait()
       +                return self.interface.is_connected
        
        
            def set_parameters(self, host, port, protocol, proxy, auto_connect):
       t@@ -290,6 +290,7 @@ class Network(threading.Thread):
                            self.start_random_interface()
                        continue
        
       +            self.pending_servers.remove(i.server)
                    if i.is_connected:
                        #if i.server in self.interfaces: raise
                        self.interfaces[i.server] = i
       t@@ -300,7 +301,7 @@ class Network(threading.Thread):
                            self.send_subscriptions()
                            self.trigger_callback('connected')
                    else:
       -                self.disconnected_servers.append(i.server)
       +                self.disconnected_servers.add(i.server)
                        if i.server in self.interfaces:
                            self.interfaces.pop(i.server)
                        if i.server in self.heights:
   DIR diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -1631,7 +1631,7 @@ class WalletSynchronizer(threading.Thread):
                    
                    if not self.network.is_connected():
                        print_error("synchronizer: waiting for interface")
       -                self.network.wait_until_connected()
       +                self.network.interface.connect_event.wait()
                        
                    self.run_interface(self.network.interface)