From 35882f7fb777dae740c84cf2b5414ee54bd8c95d Mon Sep 17 00:00:00 2001 From: ThomasV Date: Sat, 27 Oct 2012 10:24:43 +0200 Subject: [PATCH] catch ssl exception caused by timeout --- lib/interface.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/interface.py b/lib/interface.py index 6c16b36ab..488b89a2f 100644 --- a/lib/interface.py +++ b/lib/interface.py @@ -17,7 +17,7 @@ # along with this program. If not, see . -import random, socket, ast, re +import random, socket, ast, re, ssl import threading, traceback, sys, time, json, Queue from version import ELECTRUM_VERSION @@ -226,7 +226,6 @@ class Interface(threading.Thread): def init_tcp(self, host, port, proxy=None, use_ssl=True): self.init_server(host, port, proxy, use_ssl) - import ssl global proxy_modes self.connection_msg = "%s:%d"%(self.host,self.port) if self.proxy is None: @@ -257,11 +256,15 @@ class Interface(threading.Thread): try: out = '' while self.is_connected: - try: msg = self.s.recv(1024) + try: + msg = self.s.recv(1024) except socket.timeout: # ping the server with server.version, as a real ping does not exist yet self.send([('server.version', [ELECTRUM_VERSION])]) continue + except ssl.SSLError: + self.send([('server.version', [ELECTRUM_VERSION])]) + continue out += msg self.bytes_received += len(msg) if msg == '':