Skip to content
This repository was archived by the owner on May 13, 2022. It is now read-only.

Commit 1ae88a8

Browse files
committed
catch exception in throttling thread to avoid potential deadlock
1 parent cab6170 commit 1ae88a8

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

joinmarket/irc.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ def run(self):
8787
continue
8888
except Queue.Empty:
8989
pass
90+
except:
91+
log.debug("failed to send ping message on socket")
92+
break
9093
#First throttling mechanism: no more than 1 line
9194
#per self.MSG_INTERVAL seconds.
9295
x = time.time() - last_msg_time
@@ -111,9 +114,14 @@ def run(self):
111114
except Queue.Empty:
112115
#this code *should* be unreachable.
113116
continue
114-
self.irc.sock.sendall(throttled_msg+'\r\n')
115-
last_msg_time = time.time()
116-
self.msg_buffer.append((throttled_msg, last_msg_time))
117+
try:
118+
self.irc.sock.sendall(throttled_msg+'\r\n')
119+
last_msg_time = time.time()
120+
self.msg_buffer.append((throttled_msg, last_msg_time))
121+
except:
122+
log.debug("failed to send on socket")
123+
self.irc.fd.close()
124+
break
117125
self.irc.lockthrottle.wait()
118126
self.irc.lockthrottle.release()
119127

0 commit comments

Comments
 (0)