Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _do_slack_connection(self):
if self._server:
self._server.websocket.abort()
self._server = Server(self._opts['slack_token'], False)
self._server.rtm_connect()
self._parse_login_data(self._server.login_data)
self._server.websocket.sock.setblocking(1)
self.api.im.close(channel='D038BM8HQ')
while True:
try:
frame = self._server.websocket.recv()
self._handle_frame(frame)
except WebSocketConnectionClosedException:
logger.error('WebSocket connection closed.')
self._server.rtm_connect(reconnect=True)
logger.info('Restarted WebSocket connection')