tcatch ssl exception caused by timeout - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 35882f7fb777dae740c84cf2b5414ee54bd8c95d DIR parent a6e7470b1184930504591ea4255e33ff25d870a7 HTML Author: ThomasV <thomasv@gitorious> Date: Sat, 27 Oct 2012 10:24:43 +0200 catch ssl exception caused by timeout Diffstat: M lib/interface.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- DIR diff --git a/lib/interface.py b/lib/interface.py t@@ -17,7 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -import random, socket, ast, re +import random, socket, ast, re, ssl import threading, traceback, sys, time, json, Queue from version import ELECTRUM_VERSION t@@ -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: t@@ -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 == '':