Skip to content

Commit

Permalink
fix: interrupt during disconnected phase
Browse files Browse the repository at this point in the history
Because the `time.sleep` during the disconnect phase, the signal
handling is thrown off and a new bot is spawned before the `bot.hasquit`
flag can be checked. Add a check at the top of the loop to see if the
`hasquit` flag was set during a disconnect.

Fixes #1478
  • Loading branch information
HumorBaby committed Apr 1, 2019
1 parent 3e6a198 commit 9dd772d
Showing 1 changed file with 5 additions and 0 deletions.
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

0 comments on commit 9dd772d

Please sign in to comment.