Closed aw-was-here closed 7 months ago
Not as simple as just await'ing it unfortunately :(
I've taken a look at the issue on my fork, and I found the issue is with on_event
being async. If you remove the only await which can be replaced with a asyncio.create_task
, it works.
async def on_event(self, data):
if self.sock_reader._eof:
raise PyPresenceException('feed_data after feed_eof')
if not data:
return
self.sock_reader._buffer.extend(data)
self.sock_reader._wakeup_waiter()
if (self.sock_reader._transport is not None and
not self.sock_reader._paused and
len(self.sock_reader._buffer) > 2 * self.sock_reader._limit):
try:
self.sock_reader._transport.pause_reading()
except NotImplementedError:
self.sock_reader._transport = None
else:
self.sock_reader._paused = True
payload = json.loads(data[8:].decode('utf-8'))
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"])
Feel free to PR and i'll look into it further
Running a simple test of AioClient reveals that it isn't properly await'ing everything:
Error during run is: