Skip to content

Commit

Permalink
[IMP] newrelic: wrap target server initialization and skip in case od…
Browse files Browse the repository at this point in the history
…oo stop_after_init
  • Loading branch information
Shamsidinkhon committed Jun 12, 2023
1 parent e77d9a4 commit 350c261
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion newrelic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import os
from . import controllers
from odoo.tools import config

import logging
_logger = logging.getLogger(__name__)

try:

def initialization():
import odoo
target = odoo.service.server.server
if not target:
Expand Down Expand Up @@ -122,5 +124,11 @@ def _handle_exception(*args, **kwargs):
target = odoo.http.WebRequest
target._handle_exception = _nr_wrapper_handle_exception_(target._handle_exception)


try:
# the Odoo server will stop after its initialization, server will not be available for monkey-patching
if not config.get("stop_after_init"):
initialization()

except ImportError:
_logger.warn('newrelic python module not installed or other missing module')

0 comments on commit 350c261

Please sign in to comment.