async def start(self): """ Starts the gateways of the sharder gateway. This method is a coroutine. """ tasks = [] for gateway in self.gateways: task = Task(gateway.start(), KOKORO) tasks.append(task) await WaitTillExc(tasks, KOKORO) for task in tasks: task.cancel()
async def send_as_json(self, data): """ Sends the data as json to Discord on the gateway's ``.websocket``. This method is a coroutine. Parameters ---------- data : `dict` of (`str`, `Any`) items or `list` of `Any` """ data = to_json(data) tasks = [] for gateway in self.gateways: task = Task(self._send_json(gateway, data), KOKORO) tasks.append(task) done, pending = await WaitTillExc(tasks, KOKORO) for task in pending: task.cancel() for task in done: task.result()