Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def connect(self):
try:
self._websocket = await websockets.connect('wss://pubsub-edge.twitch.tv')
except Exception as e:
self._last_result = e
log.error('PubSub websocket connection failed | %s', e)
raise WSConnectionFailure('PubSub websocket connection failed. Check logs for details.')
log.info('PubSub %s connection successful', self.node)
self._listener = self.loop.create_task(self.listen())
async def delegate(self, *topics):
for x in self.connections.values():
if len(x._topics) == 50:
continue
elif len(x._topics) + len(topics) > 50:
continue
if x._websocket:
return x
await x.connect()
if x._websocket.open:
return x
raise WSConnectionFailure('Unable to delegate WebSocket. Please try again.')
raise ClientError('Maximum PubSub connections established.')