URI: 
       tadd locks to config and storage - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit e82653f4547ebebc5eee99a3f8959d8ba733c16b
   DIR parent 44edb4e2bbe930bcab486835f2a0a1d46d1948e7
  HTML Author: ThomasV <thomasv@gitorious>
       Date:   Sun, 29 Sep 2013 18:33:54 +0200
       
       add locks to config and storage
       
       Diffstat:
         M lib/simple_config.py                |      20 +++++++++++---------
         M lib/wallet.py                       |      17 ++++++++---------
       
       2 files changed, 19 insertions(+), 18 deletions(-)
       ---
   DIR diff --git a/lib/simple_config.py b/lib/simple_config.py
       t@@ -1,11 +1,9 @@
       -import json, ast
       -import os, ast
       -from util import user_dir, print_error
       -
       -from version import ELECTRUM_VERSION, SEED_VERSION
       -
       -
       +import json
       +import ast
       +import threading
       +import os
        
       +from util import user_dir, print_error
        
        
        
       t@@ -17,6 +15,7 @@ user configurations from electrum.conf into separate dictionaries within
        a SimpleConfig instance then reads the wallet file.
        """
            def __init__(self, options={}):
       +        self.lock = threading.Lock()
        
                # system conf, readonly
                self.system_config = {}
       t@@ -65,8 +64,11 @@ a SimpleConfig instance then reads the wallet file.
                        print "Warning: not changing '%s' because it was set in the system configuration"%key
        
                else:
       -            self.user_config[key] = value
       -            if save: self.save_user_config()
       +
       +            with self.lock:
       +                self.user_config[key] = value
       +                if save: 
       +                    self.save_user_config()
        
        
        
   DIR diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -68,6 +68,7 @@ from version import ELECTRUM_VERSION, SEED_VERSION
        class WalletStorage:
        
            def __init__(self, config):
       +        self.lock = threading.Lock()
                self.data = {}
                self.file_exists = False
                self.init_path(config)
       t@@ -110,15 +111,13 @@ class WalletStorage:
        
            def put(self, key, value, save = True):
        
       -        if self.data.get(key) is not None:
       -            self.data[key] = value
       -        else:
       -            # add key to wallet config
       -            self.data[key] = value
       -
       -        if save: 
       -            self.write()
       -
       +        with self.lock:
       +            if value is not None:
       +                self.data[key] = value
       +            else:
       +                self.data.pop[key]
       +            if save: 
       +                self.write()
        
            def write(self):
                s = repr(self.data)