rembo10/headphones — pull request #2022 by jmullan (2014-11-24 08:11:07+00:00)
Title: Unify locking and sleeping mechanisms

- Added a new locking and rate limiting class
- Moved locks closer to actual calls to musicbrainz server
- Changed time.sleep(x) calls to add sleep time to the lock (will be used by the next request)
- Changed at least one sleep call to a thread.join() for the same amount of time

Notes:
- Not sure if the fake lock class is really needed, but the regular lock class with time zero is not equivalent since it makes all uses of it synchronous
- Still thinking a little about the queue for accepting extra sleep time. Perhaps it should recalculate the wait time from the last request instead of blindly sleeping. The queue at least allows sleep to be scheduled without re-locking the lock
- Unindenting big blocks makes the changes look bigger than they are.