Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
odoo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-foodcoops
odoo
Commits
9b200321
Commit
9b200321
authored
Mar 20, 2021
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Connector Runner : permit other than localhost address connection
parent
036306df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
__init__.py
extra_addons/connector/jobrunner/__init__.py
+6
-1
runner.py
extra_addons/connector/jobrunner/runner.py
+6
-6
No files found.
extra_addons/connector/jobrunner/__init__.py
View file @
9b200321
...
@@ -49,7 +49,12 @@ class ConnectorRunnerThread(Thread):
...
@@ -49,7 +49,12 @@ class ConnectorRunnerThread(Thread):
Thread
.
__init__
(
self
)
Thread
.
__init__
(
self
)
self
.
daemon
=
True
self
.
daemon
=
True
port
=
os
.
environ
.
get
(
'ODOO_CONNECTOR_PORT'
)
or
config
[
'xmlrpc_port'
]
port
=
os
.
environ
.
get
(
'ODOO_CONNECTOR_PORT'
)
or
config
[
'xmlrpc_port'
]
self
.
runner
=
ConnectorRunner
(
port
or
8069
)
host
=
config
[
'xmlrpc_interface'
]
or
'localhost'
# host parameter has been introduced to consider
# case when Odoo is listening on VPN address
# the runner _async_http_get function called in run_jobs()
# was written with 'localhost' in urlopen() url string
self
.
runner
=
ConnectorRunner
(
host
,
port
or
8069
)
def
run
(
self
):
def
run
(
self
):
# sleep a bit to let the workers start at ease
# sleep a bit to let the workers start at ease
...
...
extra_addons/connector/jobrunner/runner.py
View file @
9b200321
...
@@ -161,7 +161,7 @@ def _openerp_now():
...
@@ -161,7 +161,7 @@ def _openerp_now():
return
_datetime_to_epoch
(
dt
)
return
_datetime_to_epoch
(
dt
)
def
_async_http_get
(
port
,
db_name
,
job_uuid
):
def
_async_http_get
(
host
,
port
,
db_name
,
job_uuid
):
# Method to set failed job (due to timeout, etc) as pending,
# Method to set failed job (due to timeout, etc) as pending,
# to avoid keeping it as enqueued.
# to avoid keeping it as enqueued.
def
set_job_pending
():
def
set_job_pending
():
...
@@ -178,10 +178,9 @@ def _async_http_get(port, db_name, job_uuid):
...
@@ -178,10 +178,9 @@ def _async_http_get(port, db_name, job_uuid):
# TODO: better way to HTTP GET asynchronously (grequest, ...)?
# TODO: better way to HTTP GET asynchronously (grequest, ...)?
# if this was python3 I would be doing this with
# if this was python3 I would be doing this with
# asyncio, aiohttp and aiopg
# asyncio, aiohttp and aiopg
# TODO: Make any local address to be available (instead of localhost only)
def
urlopen
():
def
urlopen
():
url
=
(
'http://
localhost
:
%
s/connector/runjob?db=
%
s&job_uuid=
%
s'
%
url
=
(
'http://
%
s
:
%
s/connector/runjob?db=
%
s&job_uuid=
%
s'
%
(
port
,
db_name
,
job_uuid
))
(
host
,
port
,
db_name
,
job_uuid
))
try
:
try
:
# we are not interested in the result, so we set a short timeout
# 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
# but not too short so we trap and log hard configuration errors
...
@@ -275,7 +274,8 @@ class Database(object):
...
@@ -275,7 +274,8 @@ class Database(object):
class
ConnectorRunner
(
object
):
class
ConnectorRunner
(
object
):
def
__init__
(
self
,
port
=
8069
,
channel_config_string
=
None
):
def
__init__
(
self
,
host
,
port
=
8069
,
channel_config_string
=
None
):
self
.
host
=
host
self
.
port
=
port
self
.
port
=
port
self
.
channel_manager
=
ChannelManager
()
self
.
channel_manager
=
ChannelManager
()
if
channel_config_string
is
None
:
if
channel_config_string
is
None
:
...
@@ -322,7 +322,7 @@ class ConnectorRunner(object):
...
@@ -322,7 +322,7 @@ class ConnectorRunner(object):
_logger
.
info
(
"asking Odoo to run job
%
s on db
%
s"
,
_logger
.
info
(
"asking Odoo to run job
%
s on db
%
s"
,
job
.
uuid
,
job
.
db_name
)
job
.
uuid
,
job
.
db_name
)
self
.
db_by_name
[
job
.
db_name
]
.
set_job_enqueued
(
job
.
uuid
)
self
.
db_by_name
[
job
.
db_name
]
.
set_job_enqueued
(
job
.
uuid
)
_async_http_get
(
self
.
port
,
job
.
db_name
,
job
.
uuid
)
_async_http_get
(
self
.
host
,
self
.
port
,
job
.
db_name
,
job
.
uuid
)
def
process_notifications
(
self
):
def
process_notifications
(
self
):
for
db
in
self
.
db_by_name
.
values
():
for
db
in
self
.
db_by_name
.
values
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment