Closed micaiahparker closed 7 years ago
I'll admit to having almost no experience with asynchronous I/O styles of programming. However, it doesn't seem like it would be too difficult. The Song
and Artist
classes both have load()
functions that are implicitly called when you try to access the lyrics or songs, respectively. The load functions really have two jobs: (1) make the request, and (2) parse the response. You could separate out the parsing into parse()
methods (which the load functions call). Then you could implement a load_async()
method that is implemented as a coroutine, and calls the parse function as well. I'd assume you'd use whatever async http library you'd like. Then your code could be something like this:
artist = Artist('Taylor Swift')
eventloop.run_async_or_whatever_i_dont_know_this_stuff(artist.load_async)
# wait for all pages of songs to be loaded in parallel
for song in artist.songs:
eventloop.run_async_as_well(song.load_async)
# wait for all the songs to be loaded in parallel
# ???
# profit
Hopefully this makes some sort of sense... like I said I don't really know much about this style of development.
I'm closing this since there doesn't seem to be anything more to do here at this time. Feel free to re-open and comment with more discussion. I'd welcome a pull request with async functionality, or if you do a complete re-write from scratch, I'd be more than happy to put a link in the README.
First, really enjoying using this package. Works great!
I was hoping to use this with my discord bot, but the bot uses async and requests is blocking. If I wanted to write an async version (looking at using aiohttp) what would need to be changed?
Thanks!