Skip to content

Commit 93898b0

Browse files
committed
[IMP] queue_job: remove multi-db monkey patch
By using the X-Odoo-Database HTTP header that is natively supported by Odoo, we achieve the same result.
1 parent 52acb9d commit 93898b0

5 files changed

Lines changed: 5 additions & 31 deletions

File tree

queue_job/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from . import wizards
55
from . import jobrunner
66
from .post_init_hook import post_init_hook
7-
from .post_load import post_load
87

98
# shortcuts
109
from .job import identity_exact

queue_job/__manifest__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,4 @@
3131
"development_status": "Mature",
3232
"maintainers": ["guewen", "sbidoul"],
3333
"post_init_hook": "post_init_hook",
34-
"post_load": "post_load",
3534
}

queue_job/controllers/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ def _get_failure_values(cls, job, traceback_txt, orig_exception):
213213
save_session=False,
214214
readonly=False,
215215
)
216-
def runjob(self, db, job_uuid, **kw):
217-
http.request.session.db = db
216+
def runjob(self, job_uuid, **kw):
218217
env = http.request.env(user=SUPERUSER_ID)
219218
job = self._acquire_job(env, job_uuid)
220219
if not job:

queue_job/jobrunner/runner.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,17 @@ def _async_http_get(scheme, host, port, user, password, db_name, job_uuid):
9090
# if this was python3 I would be doing this with
9191
# asyncio, aiohttp and aiopg
9292
def urlopen():
93-
url = f"{scheme}://{host}:{port}/queue_job/runjob?db={db_name}&job_uuid={job_uuid}"
93+
url = f"{scheme}://{host}:{port}/queue_job/runjob?job_uuid={job_uuid}"
9494
# pylint: disable=except-pass
9595
try:
9696
auth = None
9797
if user:
9898
auth = (user, password)
9999
# we are not interested in the result, so we set a short timeout
100100
# but not too short so we trap and log hard configuration errors
101-
response = requests.get(url, timeout=1, auth=auth)
101+
response = requests.get(
102+
url, timeout=1, auth=auth, headers={"X-Odoo-Database": db_name}
103+
)
102104

103105
# raise_for_status will result in either nothing, a Client Error
104106
# for HTTP Response codes between 400 and 500 or a Server Error

queue_job/post_load.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)