From 0fb91abfb85e0ca394ae9ed1c3bf857ac0f7a2e2 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 6 Oct 2010 23:03:27 +0200 Subject: pycurl cleanup --- module/ThreadManager.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'module/ThreadManager.py') 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 -- cgit v1.2.3