tsocket: retry on EAGAIN - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 803b292d9d27338e2ac01d1972f6c669aa95b58f DIR parent 1650eefdd3b10b05973d0e501c46b8084747b22b HTML Author: ThomasV <thomasv@gitorious> Date: Mon, 2 Sep 2013 21:16:57 +0200 socket: retry on EAGAIN Diffstat: M lib/interface.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 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, ssl +import random, socket, ast, re, ssl, errno import threading, traceback, sys, time, json, Queue from version import ELECTRUM_VERSION, PROTOCOL_VERSION t@@ -404,10 +404,16 @@ class Interface(threading.Thread): try: sent = self.s.send( out ) out = out[sent:] - except: - # this happens when we get disconnected - print_error( "Not connected, cannot send" ) - return None + except socket.error,e: + if e[0] in (errno.EWOULDBLOCK,errno.EAGAIN): + print_error( "EAGAIN: retrying") + time.sleep(0.1) + continue + else: + traceback.print_exc(file=sys.stdout) + # this happens when we get disconnected + print_error( "Not connected, cannot send" ) + return None return ids