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

Commit

Permalink
catch exception in throttling thread to avoid potential deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamISZ committed Jan 5, 2016
1 parent cab6170 commit 1ae88a8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions joinmarket/irc.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ def run(self):
continue
except Queue.Empty:
pass
except:
log.debug("failed to send ping message on socket")
break
#First throttling mechanism: no more than 1 line
#per self.MSG_INTERVAL seconds.
x = time.time() - last_msg_time
Expand All @@ -111,9 +114,14 @@ def run(self):
except Queue.Empty:
#this code *should* be unreachable.
continue
self.irc.sock.sendall(throttled_msg+'\r\n')
last_msg_time = time.time()
self.msg_buffer.append((throttled_msg, last_msg_time))
try:
self.irc.sock.sendall(throttled_msg+'\r\n')
last_msg_time = time.time()
self.msg_buffer.append((throttled_msg, last_msg_time))
except:
log.debug("failed to send on socket")
self.irc.fd.close()
break
self.irc.lockthrottle.wait()
self.irc.lockthrottle.release()

Expand Down

0 comments on commit 1ae88a8

Please sign in to comment.