diff options
Diffstat (limited to 'pyload')
-rw-r--r-- | pyload/database/DatabaseBackend.py | 8 | ||||
-rw-r--r-- | pyload/remote/WSClient.py | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/pyload/database/DatabaseBackend.py b/pyload/database/DatabaseBackend.py index 99a406d9c..2244a3026 100644 --- a/pyload/database/DatabaseBackend.py +++ b/pyload/database/DatabaseBackend.py @@ -32,6 +32,7 @@ except: DB = None DB_VERSION = 6 + def set_DB(db): global DB DB = db @@ -132,6 +133,7 @@ class DatabaseBackend(Thread): self.setDaemon(True) self.core = core self.manager = None # set later + self.error = None self.running = Event() self.jobs = Queue() @@ -183,6 +185,8 @@ class DatabaseBackend(Thread): def run(self): try: self.init() + except Exception, e: + self.error = e finally: self.running.set() @@ -422,9 +426,12 @@ class DatabaseBackend(Thread): self.jobs.put(job) def queue(self, f, *args, **kwargs): + # Raise previous error of initialization + if self.error: raise self.error args = (self, ) + args job = DatabaseJob(f, *args, **kwargs) self.jobs.put(job) + # only wait when db is running if self.running.isSet(): job.wait() return job.result @@ -443,6 +450,7 @@ class DatabaseBackend(Thread): return getattr(sub, attr) raise AttributeError(attr) + if __name__ == "__main__": db = DatabaseBackend() db.setup() diff --git a/pyload/remote/WSClient.py b/pyload/remote/WSClient.py index 793a6ef28..0e58c6afa 100644 --- a/pyload/remote/WSClient.py +++ b/pyload/remote/WSClient.py @@ -15,7 +15,7 @@ class WSClient: self.ws = None def connect(self): - self.ws = create_connection(self.URL) + self.ws = create_connection(self.url) def close(self): self.ws.close() |