anoadragon453 / busty

A bot for the Busty Discord server.
MIT License
6 stars 2 forks source link

Exceptions raised during `play_next_song` aren't immediately raised #116

Open anoadragon453 opened 2 years ago

anoadragon453 commented 2 years ago

Testing with a Python 3.10 system that doesn't have libopus installed (and thus is unable to play tracks) should raise a nextcord.opus.OpusNotLoaded Exception upon attempting to play a song. What I noticed after #78 merged is that this exception is still raised, but does not get printed until the process is killed:

$ BUSTY_DISCORD_TOKEN=<redacted> python ./main.py 
We have logged in as Busty Dev#1234.
^CTask exception was never retrieved  # notice the ^C here indicating when I sent a SIGINT (ctrl-C)
future: <Task finished name='Task-51' coro=<play_next_song() done, defined at /home/user/code/busty/./main.py:511> exception=OpusNotLoaded()>
Traceback (most recent call last):
  File "/home/user/code/busty/./main.py", line 581, in play_next_song
    active_voice_client.play(
  File "/nix/store/4g63yzrbr75r95ks0289f3gf0hl42mhv-python3-3.10.5-env/lib/python3.10/site-packages/nextcord/voice_client.py", line 607, in play
    self.encoder = opus.Encoder()
  File "/nix/store/4g63yzrbr75r95ks0289f3gf0hl42mhv-python3-3.10.5-env/lib/python3.10/site-packages/nextcord/opus.py", line 365, in __init__
    _OpusStruct.get_opus_version()
  File "/nix/store/4g63yzrbr75r95ks0289f3gf0hl42mhv-python3-3.10.5-env/lib/python3.10/site-packages/nextcord/opus.py", line 358, in get_opus_version
    raise OpusNotLoaded()
nextcord.opus.OpusNotLoaded

Reverting #78 locally causes the Exception to be printed immediately.

I did come across https://github.com/python/cpython/commit/7ce1c6fb579a01bb184224a10019039fde9c8eaf, however I think this is a red herring, as !stop, and thus .cancel(), has not been called on the task. Good to keep in mind for the future however.

I'm not thrilled that it's hiding exceptions until the process is killed (potentially after other logging occurs, confusing the log timeline).

anoadragon453 commented 2 years ago

I think this would be fixed by https://github.com/anoadragon453/busty/issues/123.