diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-12-21 21:55:27 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-12-21 21:55:27 +0100 |
commit | 7ad527d925f45c533a53a871dc18c294624d0b5f (patch) | |
tree | 0f6a91bfb4625b9132ff43b7de5b0d2af1231008 | |
parent | Freenode Verification: freenodeX45dmg.ver (diff) | |
download | pyload-7ad527d925f45c533a53a871dc18c294624d0b5f.tar.xz |
partial integrated new dl backend (completly unusable atm)
-rw-r--r-- | module/PluginThread.py | 4 | ||||
-rw-r--r-- | module/ThreadManager.py | 18 | ||||
-rw-r--r-- | module/network/Browser.py | 4 | ||||
-rw-r--r-- | module/network/HTTPBase.py | 63 | ||||
-rwxr-xr-x | pyLoadCore.py | 2 |
5 files changed, 38 insertions, 53 deletions
diff --git a/module/PluginThread.py b/module/PluginThread.py index 6950ec8d7..d997fcde5 100644 --- a/module/PluginThread.py +++ b/module/PluginThread.py @@ -108,7 +108,7 @@ class PluginThread(Thread): def clean(self, pyfile): """ set thread unactive and clean pyfile """ - pyfile.plugin.req.clean() + #pyfile.plugin.req.clean() self.active = False pyfile.release() @@ -267,7 +267,7 @@ class DownloadThread(PluginThread): self.m.log.info(_("Download finished: %s") % pyfile.name) - pyfile.plugin.req.clean() + #pyfile.plugin.req.clean() self.m.core.hookManager.downloadFinished(pyfile) diff --git a/module/ThreadManager.py b/module/ThreadManager.py index 1b37bdfed..e975f52a1 100644 --- a/module/ThreadManager.py +++ b/module/ThreadManager.py @@ -25,7 +25,7 @@ from threading import Event from time import sleep from traceback import print_exc from random import choice -import pycurl +#import pycurl import PluginThread from module.network.Request import getURL @@ -51,7 +51,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() @@ -126,6 +126,7 @@ class ThreadManager: while [x.active.plugin.waiting for x in self.threads if x.active].count(True) != 0: sleep(0.25) + sleep(0.25) ip = self.getIP() @@ -183,15 +184,6 @@ class ThreadManager: free[0].put("quit") - def cleanPyCurl(self): - 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""" @@ -236,7 +228,3 @@ class ThreadManager: else: thread = PluginThread.DecrypterThread(self, job) - - def cleanup(self): - """do global cleanup""" - pycurl.global_cleanup() diff --git a/module/network/Browser.py b/module/network/Browser.py index 6277f3a45..c0742c4ff 100644 --- a/module/network/Browser.py +++ b/module/network/Browser.py @@ -1,8 +1,8 @@ from HTTPBase import HTTPBase from HTTPDownload import HTTPDownload +from XDCCBase import XDCCDownload -from os.path import exists -from randowm import randint +from random import randint import zlib from cookielib import CookieJar diff --git a/module/network/HTTPBase.py b/module/network/HTTPBase.py index fe654d4dd..753c6c0f1 100644 --- a/module/network/HTTPBase.py +++ b/module/network/HTTPBase.py @@ -213,38 +213,36 @@ class PyLoadHTTPHandler(HTTPHandler): if not host: raise URLError('no host given') - try: - need_new_connection = 1 - h = self._connections.get(host) - if not h is None: - try: - self._start_connection(h, req) - except socket.error, e: - r = None - else: - try: r = h.getresponse() - except ResponseNotReady, e: r = None - - if r is None or r.version == 9: - # httplib falls back to assuming HTTP 0.9 if it gets a - # bad header back. This is most likely to happen if - # the socket has been closed by the server since we - # last used the connection. - if DEBUG: print "failed to re-use connection to %s" % host - h.close() - else: - if DEBUG: print "re-using connection to %s" % host - need_new_connection = 0 - if need_new_connection: - if DEBUG: print "creating new connection to %s" % host - h = http_class(host) - h.sourceAddress = self.sourceAddress - h.socksProxy = self.socksProxy - self._connections[host] = h + need_new_connection = 1 + h = self._connections.get(host) + if not h is None: + try: self._start_connection(h, req) - r = h.getresponse() - except socket.error, err: - raise URLError(err) + except socket.error, e: + r = None + else: + try: r = h.getresponse() + except ResponseNotReady, e: r = None + + if r is None or r.version == 9: + # httplib falls back to assuming HTTP 0.9 if it gets a + # bad header back. This is most likely to happen if + # the socket has been closed by the server since we + # last used the connection. + if DEBUG: print "failed to re-use connection to %s" % host + h.close() + else: + if DEBUG: print "re-using connection to %s" % host + need_new_connection = 0 + if need_new_connection: + if DEBUG: print "creating new connection to %s" % host + h = http_class(host) + h.sourceAddress = self.sourceAddress + h.socksProxy = self.socksProxy + self._connections[host] = h + self._start_connection(h, req) + r = h.getresponse() + # if not a persistent connection, don't try to reuse it if r.will_close: self._remove_connection(host) @@ -327,7 +325,8 @@ class HTTPBase(): req.add_data(post) req.add_header("Accept", "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5") - + req.add_header("Accept-Language", "en-US,en") + if referer: req.add_header("Referer", referer) diff --git a/pyLoadCore.py b/pyLoadCore.py index 17d5d3b34..805270c59 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -66,7 +66,6 @@ from module.FileDatabase import PyFile from module.Scheduler import Scheduler from module.JsEngine import JsEngine - from codecs import getwriter if os.name == "nt": enc = "cp850" @@ -534,7 +533,6 @@ class Core(object): finally: self.files.syncSave() - self.threadManager.cleanup() self.shuttedDown = True self.deletePidFile() |