Don't put non-kwargs after unpacked list, handle ConnectionResetError
This commit is contained in:
parent
c833d9dbb6
commit
d6134d71a3
2 changed files with 8 additions and 2 deletions
|
@ -100,7 +100,8 @@ class Bot(object):
|
|||
|
||||
def reconnect(self, event):
|
||||
server_details = self.database.get_server(event["server_id"])
|
||||
server = self.add_server(*server_details, False)
|
||||
add_server_args = server_details + [False]
|
||||
server = self.add_server(*add_server_args)
|
||||
if self.connect(server):
|
||||
self.servers[server.fileno()] = server
|
||||
else:
|
||||
|
|
|
@ -154,7 +154,12 @@ class Server(object):
|
|||
"encoding", "utf8")
|
||||
fallback_encoding = self.bot.database.get_server_setting(
|
||||
self.id, "fallback-encoding", "latin-1")
|
||||
data = self.read_buffer + self.socket.recv(4096)
|
||||
data = b""
|
||||
try:
|
||||
data = self.read_buffer + self.socket.recv(4096)
|
||||
except ConnectionResetError:
|
||||
self.disconnect()
|
||||
return []
|
||||
self.read_buffer = b""
|
||||
data_lines = [line.strip(b"\r") for line in data.split(b"\n")]
|
||||
if data_lines[-1]:
|
||||
|
|
Loading…
Reference in a new issue