Browse Source

Change Event to Future and add versionadded tag

pull/9842/head
Imayhaveborkedit 12 months ago
parent
commit
6f74fb7213
  1. 7
      discord/player.py
  2. 2
      discord/voice_client.py

7
discord/player.py

@ -718,7 +718,7 @@ class AudioPlayer(threading.Thread):
self._current_error: Optional[Exception] = None self._current_error: Optional[Exception] = None
self._lock: threading.Lock = threading.Lock() self._lock: threading.Lock = threading.Lock()
self._end_async: asyncio.Event = asyncio.Event(loop=client.loop) self._end_future = client.loop.create_future()
if after is not None and not callable(after): if after is not None and not callable(after):
raise TypeError('Expected a callable for the "after" parameter.') raise TypeError('Expected a callable for the "after" parameter.')
@ -778,7 +778,7 @@ class AudioPlayer(threading.Thread):
finally: finally:
self._call_after() self._call_after()
self._cleanup() self._cleanup()
self.client.loop.call_soon_threadsafe(self._end_async.set) self.client.loop.call_soon_threadsafe(self._end_future.set_result, self._current_error)
def _call_after(self) -> None: def _call_after(self) -> None:
error = self._current_error error = self._current_error
@ -828,8 +828,7 @@ class AudioPlayer(threading.Thread):
self.resume(update_speaking=False) self.resume(update_speaking=False)
async def wait_async(self) -> Optional[Exception]: async def wait_async(self) -> Optional[Exception]:
await self._end_async.wait() return await self._end_future
return self._current_error
def _speak(self, speaking: SpeakingState) -> None: def _speak(self, speaking: SpeakingState) -> None:
try: try:

2
discord/voice_client.py

@ -543,6 +543,8 @@ class VoiceClient(VoiceProtocol):
Waits for the audio player to finish playback and returns any encountered error. Waits for the audio player to finish playback and returns any encountered error.
.. versionadded:: 2.4
Returns Returns
-------- --------
Optional[:class:`Exception`] Optional[:class:`Exception`]

Loading…
Cancel
Save