Update gateway.py
to make self._zlib reinitialize whenever a connection starts
@@ -96,8 +96,6 @@ class GatewayServer:
self.connected = False
self.resumable = False
- self._zlib = zlib.decompressobj()
-
self.voice_data = {} #voice connections dependent on current (connected) session
#guild helper functions
@@ -239,6 +237,7 @@ class GatewayServer:
#modified version of function run_4ever from https://github.com/scrubjay55/Reddit_ChatBot_Python/blob/master/Reddit_ChatBot_Python/Utils/WebSockClient.py (Apache License 2.0)
def run(self, auto_reconnect=True):
while auto_reconnect:
+ self._zlib = zlib.decompressobj()
self.ws.run_forever(ping_interval=10, ping_timeout=5, http_proxy_host=self.proxy_host, http_proxy_port=self.proxy_port)
if isinstance(self._last_err, websocket._exceptions.WebSocketAddressException) or isinstance(self._last_err, websocket._exceptions.WebSocketTimeoutException):
if self.resumable:
@@ -257,4 +256,5 @@ class GatewayServer:
self.resumable = True
return 0
if not auto_reconnect:
+ self._zlib = zlib.decompressobj()
self.ws.run_forever(ping_interval=10, ping_timeout=5, http_proxy_host=self.proxy_host, http_proxy_port=self.proxy_port)
