diff --git a/queue_job/controllers/main.py b/queue_job/controllers/main.py index 51a8da8a02..2f4d60dff8 100644 --- a/queue_job/controllers/main.py +++ b/queue_job/controllers/main.py @@ -34,19 +34,7 @@ def _try_perform_job(self, env, job): env.cr.commit() _logger.debug("%s done", job) - @http.route("/queue_job/session", type="http", auth="none") - def session(self): - """Used by the jobrunner to spawn a session - - The queue jobrunner uses anonymous sessions when it calls - ``/queue_job/runjob``. To avoid having thousands of anonymous - sessions, before running jobs, it creates a ``requests.Session`` - and does a GET on ``/queue_job/session``, providing it a cookie - which will be used for subsequent calls to runjob. - """ - return "" - - @http.route("/queue_job/runjob", type="http", auth="none") + @http.route("/queue_job/runjob", type="http", auth="none", save_session=False) def runjob(self, db, job_uuid, **kw): http.request.session.db = db env = http.request.env(user=odoo.SUPERUSER_ID) diff --git a/queue_job/jobrunner/runner.py b/queue_job/jobrunner/runner.py index 85996b98f3..a281eda0b5 100644 --- a/queue_job/jobrunner/runner.py +++ b/queue_job/jobrunner/runner.py @@ -157,9 +157,6 @@ _logger = logging.getLogger(__name__) -session = requests.Session() - - # Unfortunately, it is not possible to extend the Odoo # server command line arguments, so we resort to environment variables # to configure the runner (channels mostly). @@ -201,20 +198,7 @@ def _connection_info_for(db_name): return connection_info -session = requests.Session() - - def _async_http_get(scheme, host, port, user, password, db_name, job_uuid): - if not session.cookies: - # obtain an anonymous session - _logger.info("obtaining an anonymous session for the job runner") - url = "{}://{}:{}/queue_job/session".format(scheme, host, port) - auth = None - if user: - auth = (user, password) - response = session.get(url, timeout=30, auth=auth) - response.raise_for_status() - # Method to set failed job (due to timeout, etc) as pending, # to avoid keeping it as enqueued. def set_job_pending(): @@ -250,7 +234,7 @@ def urlopen(): auth = (user, password) # we are not interested in the result, so we set a short timeout # but not too short so we trap and log hard configuration errors - response = session.get(url, timeout=1, auth=auth) + response = requests.get(url, timeout=1, auth=auth) # raise_for_status will result in either nothing, a Client Error # for HTTP Response codes between 400 and 500 or a Server Error @@ -260,7 +244,6 @@ def urlopen(): set_job_pending() except Exception: _logger.exception("exception in GET %s", url) - session.cookies.clear() set_job_pending() thread = threading.Thread(target=urlopen)