Skip to content

Commit

Permalink
Merge pull request #1534 from HumorBaby/1478-fix-broken-interrupt-han…
Browse files Browse the repository at this point in the history
…dling-6.6.x

core: fix broken interrupt handling (6.6.x)
  • Loading branch information
dgw authored Apr 9, 2019
2 parents 20f2ca9 + 9dd772d commit a8579a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions sopel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ def signal_handler(sig, frame):
if sig == signal.SIGUSR1 or sig == signal.SIGTERM or sig == signal.SIGINT:
stderr('Got quit signal, shutting down.')
p.quit('Closing')

# Define empty variable `p` for bot
p = None
while True:
if p and p.hasquit: # Check if `hasquit` was set for bot during disconnected phase
break
try:
p = bot.Sopel(config, daemon=daemon)
if hasattr(signal, 'SIGUSR1'):
Expand Down
3 changes: 2 additions & 1 deletion sopel/irc.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ def initiate_connect(self, host, port):

def quit(self, message):
"""Disconnect from IRC and close the bot."""
self.write(['QUIT'], message)
if self.connected: # Only send QUIT message if socket is open
self.write(['QUIT'], message)
self.hasquit = True
# Wait for acknowledgement from the server. By RFC 2812 it should be
# an ERROR msg, but many servers just close the connection. Either way
Expand Down

0 comments on commit a8579a5

Please sign in to comment.