summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-09-21 18:36:56 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-09-21 18:36:56 +0200
commit1eecb5c6da3f06bc7097b59bb7a2cf484172420f (patch)
treee5539c71300ec471d094dfbe0ee8592ce01ea86d /module/plugins
parentimproved account relogin (diff)
downloadpyload-1eecb5c6da3f06bc7097b59bb7a2cf484172420f.tar.xz
some mutex for account access
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/Account.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/module/plugins/Account.py b/module/plugins/Account.py
index eac7d2a87..202a7ad67 100644
--- a/module/plugins/Account.py
+++ b/module/plugins/Account.py
@@ -20,8 +20,9 @@
from random import choice
from time import time
from traceback import print_exc
+from threading import RLock
-from module.utils import compare_time, parseFileSize
+from module.utils import compare_time, parseFileSize, lock
class WrongPassword(Exception):
pass
@@ -51,6 +52,8 @@ class Account():
self.core = manager.core
self.accounts = {}
self.infos = {} # cache for account information
+ self.lock = RLock()
+
self.timestamps = {}
self.setAccounts(accounts)
self.init()
@@ -67,6 +70,7 @@ class Account():
"""
pass
+ @lock
def _login(self, user, data):
# set timestamp for login
self.timestamps[user] = time()
@@ -132,6 +136,7 @@ class Account():
if user in self.timestamps:
del self.timestamps[user]
+ @lock
def getAccountInfo(self, name, force=False):
"""retrieve account infos for an user, do **not** overwrite this method!\\
just use it to retrieve infos in hoster plugins. see `loadAccountInfo`
@@ -161,6 +166,7 @@ class Account():
self.infos[name] = infos
elif "timestamp" in self.infos[name] and self.infos[name][
"timestamp"] + self.info_threshold * 60 < time():
+ self.logDebug("Reached timeout for account data")
self.scheduleRefresh(name)
data.update(self.infos[name])
@@ -272,6 +278,7 @@ class Account():
self.logDebug("Scheduled Account refresh for %s in %s seconds." % (user, time))
self.core.scheduler.addJob(time, self.getAccountInfo, [user, force])
+ @lock
def checkLogin(self, user):
""" checks if user is still logged in """
if user in self.timestamps: