From d29e99f6090d567910faefefa6f8a2086deb98f1 Mon Sep 17 00:00:00 2001 From: TheUntraceable <73362400+TheUntraceable@users.noreply.github.com> Date: Tue, 2 Jan 2024 09:44:55 +0000 Subject: [PATCH] Fix 'AioClient.on_event' was never awaited Asyncio expects the on_event function to *not* be a coroutine. --- pypresence/client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pypresence/client.py b/pypresence/client.py index 0f7d75e..6cb376d 100644 --- a/pypresence/client.py +++ b/pypresence/client.py @@ -1,3 +1,4 @@ +import asyncio import inspect import struct import json @@ -225,7 +226,7 @@ async def unregister_event(self, event: str, args=None): del self._events[event] # noinspection PyProtectedMember - async def on_event(self, data): + def on_event(self, data): if self.sock_reader._eof: raise PyPresenceException('feed_data after feed_eof') if not data: @@ -247,7 +248,7 @@ async def on_event(self, data): if payload["evt"] is not None: evt = payload["evt"].lower() if evt in self._events: - await self._events[evt](payload["data"]) + asyncio.create_task(self._events[evt](payload["data"])) elif evt == 'error': raise DiscordError(payload["data"]["code"], payload["data"]["message"])