electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 78f5dbb72ebb86420c46844aaad96798c6f5c3e9
parent 241b3b073ff9c5f80acc9d16e752d9b12f83666b
Author: ThomasV <thomasv@gitorious>
Date:   Wed,  6 May 2015 12:13:21 +0200

revert c64e0c0e64a0355f0813b96a6a2a4a6701d6684d

Diffstat:
Mlib/interface.py | 14++++----------
1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/lib/interface.py b/lib/interface.py @@ -59,7 +59,7 @@ class TcpInterface(threading.Thread): self.debug = False # dump network messages. can be changed at runtime using the console self.message_id = 0 self.response_queue = response_queue - self.request_queue = Queue.Queue() + self.lock = threading.Lock() self.unanswered_requests = {} # request timeouts self.request_time = False @@ -84,7 +84,8 @@ class TcpInterface(threading.Thread): result = response.get('result') if msg_id is not None: - method, params, _id, queue = self.unanswered_requests.pop(msg_id) + with self.lock: + method, params, _id, queue = self.unanswered_requests.pop(msg_id) if queue is None: queue = self.response_queue else: @@ -251,13 +252,7 @@ class TcpInterface(threading.Thread): return s def send_request(self, request, response_queue = None): - '''Queue a request. Blocking only if called from other threads.''' - self.request_queue.put((request, response_queue), threading.current_thread() != self) - - def send_requests(self): - '''Sends all queued requests''' - while self.is_connected() and not self.request_queue.empty(): - request, response_queue = self.request_queue.get() + with self.lock: method = request.get('method') params = request.get('params') r = {'id': self.message_id, 'method': method, 'params': params} @@ -332,7 +327,6 @@ class TcpInterface(threading.Thread): while self.connected: self.maybe_ping() - self.send_requests() self.get_and_process_one_response() self.change_status()