shazamio / ShazamIO

🎵 Is a free asynchronous library from reverse engineered Shazam API written in Python 3.8+ with asyncio and aiohttp.
MIT License
521 stars 76 forks source link

DeprecationWarning about event loop. #49

Closed sosopoet closed 1 year ago

sosopoet commented 1 year ago

Since upgrading to Linux Mint 21 (ubuntu 20.04) I'm seeing

DeprecationWarning: There is no current event loop loop = asyncio.get_event_loop()

Seems my Python is now version 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]

Paul Cornelius says (on StackExchange) "code will run on Python3.10 but as of 3.11 it will be an error to call asyncio.get_event_loop when there is no running loop in the current thread. Since you need loop as an argument, apparently, you must explicitly create and set it.

I tried pasting something like his suggestion, into my script in place of the 'loop = asyncio.get_event_loop()' bit, but just got a TypeError instead...

dotX12 commented 1 year ago

Since upgrading to Linux Mint 21 (ubuntu 20.04) I'm seeing

DeprecationWarning: There is no current event loop loop = asyncio.get_event_loop()

Seems my Python is now version 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]

Paul Cornelius says (on StackExchange) "code will run on Python3.10 but as of 3.11 it will be an error to call asyncio.get_event_loop when there is no running loop in the current thread. Since you need loop as an argument, apparently, you must explicitly create and set it.

I tried pasting something like his suggestion, into my script in place of the 'loop = asyncio.get_event_loop()' bit, but just got a TypeError instead...

https://github.com/dotX12/ShazamIO/blob/b05b1eb2f8e714f3b3b19e201786f59aef711317/examples/recognize_song.py#L1-L15

dotX12 commented 1 year ago

https://github.com/dotX12/ShazamIO/blob/b05b1eb2f8e714f3b3b19e201786f59aef711317/examples/recognize_song.py#L14-L15

Thank you for reporting this, not all examples have it fixed, but here is the corrected version.