summaryrefslogtreecommitdiffstats
path: root/module/ThreadManager.py
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/ThreadManager.py
parentdecrypter retry fix, status fix with pycurl error (diff)
downloadpyload-0fb91abfb85e0ca394ae9ed1c3bf857ac0f7a2e2.tar.xz
pycurl cleanup
Diffstat (limited to 'module/ThreadManager.py')
-rw-r--r--module/ThreadManager.py11
1 files changed, 11 insertions, 0 deletions
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