summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-10-06 23:03:27 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-10-06 23:03:27 +0200
commit0fb91abfb85e0ca394ae9ed1c3bf857ac0f7a2e2 (patch)
tree7a7b0118aeeba444cbb9c22716d1807f6b199997 /module
parentdecrypter retry fix, status fix with pycurl error (diff)
downloadpyload-0fb91abfb85e0ca394ae9ed1c3bf857ac0f7a2e2.tar.xz
pycurl cleanup
Diffstat (limited to 'module')
-rw-r--r--module/PluginThread.py2
-rw-r--r--module/ThreadManager.py11
-rwxr-xr-xmodule/network/Request.py10
3 files changed, 17 insertions, 6 deletions
diff --git a/module/PluginThread.py b/module/PluginThread.py
index c9f353dea..296b51bb3 100644
--- a/module/PluginThread.py
+++ b/module/PluginThread.py
@@ -336,7 +336,7 @@ class DecrypterThread(PluginThread):
except Retry:
self.m.log.info(_("Retrying %s") % self.active.name)
- self.active.plugin.preprocessing(self)
+ return self.active.plugin.preprocessing(self)
except Exception, e:
diff --git a/module/ThreadManager.py b/module/ThreadManager.py
index 365efa764..19e239c16 100644
--- a/module/ThreadManager.py
+++ b/module/ThreadManager.py
@@ -48,6 +48,7 @@ class ThreadManager:
self.reconnecting = Event()
self.reconnecting.clear()
+ self.downloaded = 0 #number of files downloaded since last cleanup
pycurl.global_init(pycurl.GLOBAL_DEFAULT)
@@ -170,6 +171,14 @@ class ThreadManager:
if self.pause or not self.core.server_methods.is_time_download(): return
+ if self.downloaded > 20:
+ if self.downloadingIds():
+ return
+ pycurl.global_cleanup()
+ pycurl.global_init(pycurl.GLOBAL_DEFAULT)
+ self.downloaded = 0
+ self.log.debug("Cleaned up resources")
+
free = [x for x in self.threads if not x.active]
occ = [x.active.pluginname for x in self.threads if x.active and not x.active.plugin.multiDL]
@@ -187,6 +196,8 @@ class ThreadManager:
if job.plugin.__type__ == "hoster":
if free:
thread = free[0]
+ self.downloaded += 1
+
thread.put(job)
else:
#put job back
diff --git a/module/network/Request.py b/module/network/Request.py
index 7c1e468eb..c0551b042 100755
--- a/module/network/Request.py
+++ b/module/network/Request.py
@@ -286,8 +286,8 @@ class Request:
self.chunkRead += chunkSize
self.dl_arrived += chunkSize
- #self.pycurl.setopt(pycurl.WRITEFUNCTION, writefunc)
- self.pycurl.setopt(pycurl.WRITEDATA, self.fp)
+ self.pycurl.setopt(pycurl.WRITEFUNCTION, writefunc)
+ #self.pycurl.setopt(pycurl.WRITEDATA, self.fp)
try:
self.pycurl.perform()
@@ -344,8 +344,8 @@ class Request:
def get_speed(self):
try:
- #return self.dl_speed
- return (self.dl_arrived / (time.time()- self.dl_time)) / 1024
+ return self.dl_speed
+ #return (self.dl_arrived / (time.time()- self.dl_time)) / 1024
except:
return 0
@@ -360,7 +360,7 @@ class Request:
def progress(self, dl_t, dl_d, up_t, up_d):
if self.abort:
- raise Exception
+ return False
self.dl_arrived = int(dl_d)
self.dl_size = int(dl_t)