bot: fix duplicate unregister KeyError and improve connection error logging
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Silently ignore KeyError when unregistering an already-removed FD from the poll loop (servers can queue multiple close events). Also include the exception message when a server connection fails at startup. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8a01aecd71
commit
63542d32e3
2 changed files with 6 additions and 3 deletions
|
|
@ -163,8 +163,8 @@ def main():
|
||||||
logger.info("Server '%s' successfully added.", srv.name)
|
logger.info("Server '%s' successfully added.", srv.name)
|
||||||
else:
|
else:
|
||||||
logger.error("Can't add server '%s'.", srv.name)
|
logger.error("Can't add server '%s'.", srv.name)
|
||||||
except:
|
except Exception as e:
|
||||||
logger.error("Unable to connect to '%s'.", srv.name)
|
logger.error("Unable to connect to '%s': %s", srv.name, e)
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,10 @@ class Bot(threading.Thread):
|
||||||
elif args[0] == "register":
|
elif args[0] == "register":
|
||||||
self._poll.register(int(args[1]), select.POLLIN | select.POLLPRI)
|
self._poll.register(int(args[1]), select.POLLIN | select.POLLPRI)
|
||||||
elif args[0] == "unregister":
|
elif args[0] == "unregister":
|
||||||
self._poll.unregister(int(args[1]))
|
try:
|
||||||
|
self._poll.unregister(int(args[1]))
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
except:
|
except:
|
||||||
logger.exception("Unhandled excpetion during action:")
|
logger.exception("Unhandled excpetion during action:")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue