Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion server_environment/server_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from odoo.addons.base_sparse_field.models.fields import Serialized

from .system_info import get_server_environment
from .system_info import get_server_environment, skip_subprocess

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -246,6 +246,8 @@ def _get_env_cols(cls, sections=None):
@classmethod
def _get_system_cols(cls):
"""Compute system fields"""
if skip_subprocess():
return {}
res = {}
for col, item in get_server_environment():
key = cls._format_key("system", col)
Expand Down
17 changes: 17 additions & 0 deletions server_environment/system_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,25 @@
import subprocess
from functools import lru_cache

import odoo
from odoo import release
from odoo.tools.config import config


def skip_subprocess():
# In the gevent worker (longpolling/websocket) running subprocesses can
# deadlock, freezing real-time updates. This system info only feeds the
# settings display, so skip the subprocess calls there.
return odoo.evented


def _get_output(cmd):
# Use assert to force developers to
# take correct action when developing
# but running `python -O` removes it completely
assert (
not skip_subprocess()
), "Subprocess must not be called, use skip_subprocess in a pre-check"
bindir = config["root_path"]
p = subprocess.Popen(
cmd, shell=True, cwd=bindir, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
Expand All @@ -22,6 +36,9 @@ def _get_output(cmd):

@lru_cache(maxsize=1)
def get_server_environment():
# Function relies mainly on subprocesses
if skip_subprocess():
return ()
# inspired by server/bin/service/web_services.py
try:
rev_id = "git:%s" % _get_output("git rev-parse HEAD")
Expand Down
Loading