diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-03-13 18:48:01 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-03-13 18:48:01 +0100 |
commit | b0ab80452769af1482e679db93abd407c608a7f6 (patch) | |
tree | 64ea3210a847b810e575cc28649b2f519671e002 /module/database | |
parent | fixed login issue (diff) | |
download | pyload-b0ab80452769af1482e679db93abd407c608a7f6.tar.xz |
cnl fix
Diffstat (limited to 'module/database')
-rw-r--r-- | module/database/DatabaseBackend.py | 26 | ||||
-rw-r--r-- | module/database/FileDatabase.py | 7 |
2 files changed, 22 insertions, 11 deletions
diff --git a/module/database/DatabaseBackend.py b/module/database/DatabaseBackend.py index 2bc6c0bb2..02e09b3b3 100644 --- a/module/database/DatabaseBackend.py +++ b/module/database/DatabaseBackend.py @@ -77,7 +77,22 @@ class DatabaseJob(): self.result = None self.exception = False - + + #import inspect + #self.frame = inspect.currentframe() + + def __repr__(self): + from os.path import basename + frame = self.frame.f_back + output = "" + for i in range(5): + output += "\t%s:%s, %s\n" % (basename(frame.f_code.co_filename), frame.f_lineno, frame.f_code.co_name) + frame = frame.f_back + del frame + del self.frame + + return "DataBase Job %s:%s\n%s" % (self.f.__name__, self.args[1:], output) + def processJob(self): try: self.result = self.f(*self.args, **self.kwargs) @@ -85,7 +100,8 @@ class DatabaseJob(): print "Database Error @", self.f.__name__, self.args[1:], self.kwargs, e print_exc() self.exception = e - self.done.set() + finally: + self.done.set() def wait(self): self.done.wait() @@ -96,8 +112,7 @@ class DatabaseBackend(Thread): Thread.__init__(self) self.setDaemon(True) self.core = core - - self.transactionLock = Lock() + self.jobs = Queue() self.setuplock = Event() @@ -127,18 +142,15 @@ class DatabaseBackend(Thread): while True: j = self.jobs.get() - self.transactionLock.acquire() if j == "quit": self.c.close() self.conn.close() - self.transactionLock.release() break j.processJob() if j.exception: self.conn.rollback() else: self.conn.commit() - self.transactionLock.release() @style.queue def shutdown(self): diff --git a/module/database/FileDatabase.py b/module/database/FileDatabase.py index c539bcaf6..528bf666d 100644 --- a/module/database/FileDatabase.py +++ b/module/database/FileDatabase.py @@ -59,6 +59,7 @@ class FileHandler: self.jobCache = {} self.lock = RLock() #@TODO should be a Lock w/o R + #self.lock._Verbose__verbose = True self.filecount = -1 # if an invalid value is set get current value from db self.unchanged = False #determines if any changes was made since last call @@ -473,10 +474,8 @@ class FileHandler: def updateFileInfo(self, data, pid): """ updates file info (name, size, status, url)""" ids = self.db.updateLinkInfo(data) - - for fid in ids: - e = UpdateEvent("file", fid, "collector" if not self.getFile(fid).package().queue else "queue") - self.core.pullManager.addEvent(e) + e = UpdateEvent("pack", pid, "collector" if not self.getPackage(pid).queue else "queue") + self.core.pullManager.addEvent(e) def checkPackageFinished(self, pyfile): """ checks if package is finished and calls hookmanager """ |