summaryrefslogtreecommitdiffstats
path: root/module/ThreadManager.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-12-27 21:18:29 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-12-27 21:18:29 +0100
commit9509a6444bbb538e136ed899d94aab32be629383 (patch)
treeac8532b20912a3e5be6ff73443520a7f31f5806a /module/ThreadManager.py
parentencoding fix (diff)
downloadpyload-9509a6444bbb538e136ed899d94aab32be629383.tar.xz
new curl download backend - support for chunked dl, resume
Diffstat (limited to 'module/ThreadManager.py')
-rw-r--r--module/ThreadManager.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/module/ThreadManager.py b/module/ThreadManager.py
index 0a2ce674b..c5744cb92 100644
--- a/module/ThreadManager.py
+++ b/module/ThreadManager.py
@@ -26,6 +26,8 @@ from time import sleep
from traceback import print_exc
from random import choice
+import pycurl
+
import PluginThread
from module.network.Request import getURL
@@ -50,7 +52,7 @@ class ThreadManager:
self.reconnecting.clear()
self.downloaded = 0 #number of files downloaded since last cleanup
- #pycurl.global_init(pycurl.GLOBAL_DEFAULT)
+ pycurl.global_init(pycurl.GLOBAL_DEFAULT)
for i in range(0, self.core.config.get("general", "max_downloads")):
self.createThread()
@@ -147,7 +149,6 @@ class ThreadManager:
sleep(1)
ip = self.getIP()
self.core.hookManager.afterReconnecting(ip)
- self.closeAllConnecions()
self.log.info(_("Reconnected, new IP: %s") % ip)
@@ -184,6 +185,16 @@ class ThreadManager:
free[0].put("quit")
+ def cleanPycurl(self):
+ """ make a global curl cleanup (currently ununused """
+ if self.downloadingIds() or self.processingIds():
+ return False
+ pycurl.global_cleanup()
+ pycurl.global_init(pycurl.GLOBAL_DEFAULT)
+ self.downloaded = 0
+ self.log.debug("Cleaned up pycurl")
+ return True
+
#----------------------------------------------------------------------
def assignJob(self):
"""assing a job to a thread if possible"""
@@ -229,8 +240,6 @@ class ThreadManager:
else:
thread = PluginThread.DecrypterThread(self, job)
- def closeAllConnecions(self):
- """closes all connections, when a reconnect was made """
- for pyfile in self.core.files.cache.itervalues():
- if pyfile.plugin and pyfile.plugin.req:
- pyfile.plugin.req.http.closeAll()
+ def cleanup(self):
+ """do global cleanup, should be called when finished with pycurl"""
+ pycurl.global_cleanup()