Add opener to env

This commit is contained in:
Ruud
2014-06-06 10:53:08 +02:00
parent 426155e65c
commit f0daee669b
3 changed files with 4 additions and 4 deletions
+1 -2
View File
@@ -40,7 +40,6 @@ class Plugin(object):
http_time_between_calls = 0 http_time_between_calls = 0
http_failed_request = {} http_failed_request = {}
http_failed_disabled = {} http_failed_disabled = {}
http_opener = requests.Session()
def __new__(cls, *args, **kwargs): def __new__(cls, *args, **kwargs):
new_plugin = super(Plugin, cls).__new__(cls) new_plugin = super(Plugin, cls).__new__(cls)
@@ -184,7 +183,7 @@ class Plugin(object):
headers['Connection'] = headers.get('Connection', 'keep-alive') headers['Connection'] = headers.get('Connection', 'keep-alive')
headers['Cache-Control'] = headers.get('Cache-Control', 'max-age=0') headers['Cache-Control'] = headers.get('Cache-Control', 'max-age=0')
r = self.http_opener r = Env.get('http_opener')
# Don't try for failed requests # Don't try for failed requests
if self.http_failed_disabled.get(host, 0) > 0: if self.http_failed_disabled.get(host, 0) > 0:
+1 -2
View File
@@ -24,8 +24,7 @@ class Env(object):
_quiet = False _quiet = False
_daemonized = False _daemonized = False
_desktop = None _desktop = None
_engine = None _http_opener = None
_session = None
''' Data paths and directories ''' ''' Data paths and directories '''
_app_dir = "" _app_dir = ""
+2
View File
@@ -18,6 +18,7 @@ from couchpotato.api import NonBlockHandler, ApiHandler
from couchpotato.core.event import fireEventAsync, fireEvent from couchpotato.core.event import fireEventAsync, fireEvent
from couchpotato.core.helpers.encoding import sp from couchpotato.core.helpers.encoding import sp
from couchpotato.core.helpers.variable import getDataDir, tryInt from couchpotato.core.helpers.variable import getDataDir, tryInt
import requests
from tornado.httpserver import HTTPServer from tornado.httpserver import HTTPServer
from tornado.web import Application, StaticFileHandler, RedirectHandler from tornado.web import Application, StaticFileHandler, RedirectHandler
@@ -141,6 +142,7 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
Env.set('data_dir', sp(data_dir)) Env.set('data_dir', sp(data_dir))
Env.set('log_path', sp(os.path.join(log_dir, 'CouchPotato.log'))) Env.set('log_path', sp(os.path.join(log_dir, 'CouchPotato.log')))
Env.set('db', db) Env.set('db', db)
Env.set('http_opener', requests.Session())
Env.set('cache_dir', cache_dir) Env.set('cache_dir', cache_dir)
Env.set('cache', FileSystemCache(python_cache)) Env.set('cache', FileSystemCache(python_cache))
Env.set('console_log', options.console_log) Env.set('console_log', options.console_log)