+class Throttle:
+ """throttle decorator"""
+ def __init__(self, wait):
+ self.wait = wait
+ self.last_called = datetime.now()
+
+ def __call__(self, func):
+ def wrapper(*args, **kwargs):
+ while self.last_called + self.wait > datetime.now():
+ sleep(0.1)
+ result = func(*args, **kwargs)
+ self.last_called = datetime.now()
+ return result
+ return wrapper
+
+
+class MPDSimaException(Exception):
+ """Generic MPD_sima Exception"""
+
+
+# http client exceptions (for webservices)
+class WSError(MPDSimaException):
+ pass
+
+
+class WSNotFound(WSError):
+ pass
+
+
+class WSTimeout(WSError):
+ pass
+
+
+class WSHTTPError(WSError):
+ pass
+
+
+class PluginException(MPDSimaException):
+ pass
+