Hacker News new | ask | show | jobs
by wmichelin 686 days ago
Hardcoded sleeps for some reason, nice /s

https://github.com/cgzirim/not-shazam/blob/888070f3434acbc0a...

2 comments

It's to go around the ban of the IP / account by Spotify and to be softer with them, you have to wait between two requests to download songs.
I also use sleep a lot in my code when interfacing with third-party services (multiprocess usually so it's not blocking things, though I'd also totally see myself using a callback pattern or so if the caller can handle those). When it's more than an ad-hoc piece of code, it generally measures how long ago the previous request finished to determine how long to sleep if the next call is made within the cool-off period. If you're not doing that... please don't interface with my server