Merge branch 'develop' of github.com:RuudBurger/CouchPotatoServer into develop

This commit is contained in:
Ruud
2014-09-17 12:59:29 +02:00
11 changed files with 71 additions and 20 deletions
+19
View File
@@ -1,3 +1,4 @@
import threading
from urllib import quote
from urlparse import urlparse
import glob
@@ -35,6 +36,8 @@ class Plugin(object):
_needs_shutdown = False
_running = None
_locks = {}
user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20130519 Firefox/24.0'
http_last_use = {}
http_time_between_calls = 0
@@ -400,3 +403,19 @@ class Plugin(object):
def isEnabled(self):
return self.conf(self.enabled_option) or self.conf(self.enabled_option) is None
def acquireLock(self, key):
lock = self._locks.get(key)
if not lock:
self._locks[key] = threading.RLock()
log.debug('Acquiring lock: %s', key)
self._locks.get(key).acquire()
def releaseLock(self, key):
lock = self._locks.get(key)
if lock:
log.debug('Releasing lock: %s', key)
self._locks.get(key).release()