(self, request)
return request
Return a context manager that combines a profiler and ``request``.
Return a context manager that combines a profiler and ``request``.
Return a context manager that combines a profiler and request .
def get_profiler_context_manager(self, request):
        """ Return a context manager that combines a profiler and ``request``. """
        if request.session.profile_session and request.session.db:
            if request.session.profile_expiration < str(datetime.now()):
                # avoid having session profiling for too long if user forgets to disable profiling
                request.session.profile_session = None
                _logger.warning("Profiling expiration reached, disabling profiling")
            elif 'set_profiling' in request.httprequest.path:
                _logger.debug("Profiling disabled on set_profiling route")
            elif request.httprequest.path.startswith('/longpolling'):
                _logger.debug("Profiling disabled for longpolling")
            elif odoo.evented:
                # only longpolling should be in a evented server, but this is an additional safety
                _logger.debug("Profiling disabled for evented server")
            else:
                try:
                    prof = profiler.Profiler(
                        db=request.session.db,
                        description=request.httprequest.full_path,
                        profile_session=request.session.profile_session,
                        collectors=request.session.profile_collectors,
                        params=request.session.profile_params,
                    )
                    return profiler.Nested(prof, request)
                except Exception:
                    _logger.exception("Failure during Profiler creation")
                    request.session.profile_session = None
        return request
def get_profiler_context_manager ( self , request ) : if request . session . profile_session and request . session . db : if request . session . profile_expiration < str ( datetime . now ( ) ) : # avoid having session profiling for too long if user forgets to disable profiling request . session . profile_session = None _logger . warning ( "Profiling expiration reached, disabling profiling" ) elif 'set_profiling' in request . httprequest . path : _logger . debug ( "Profiling disabled on set_profiling route" ) elif request . httprequest . path . startswith ( '/longpolling' ) : _logger . debug ( "Profiling disabled for longpolling" ) elif odoo . evented : # only longpolling should be in a evented server, but this is an additional safety _logger . debug ( "Profiling disabled for evented server" ) else : try : prof = profiler . Profiler ( db = request . session . db , description = request . httprequest . full_path , profile_session = request . session . profile_session , collectors = request . session . profile_collectors , params = request . session . profile_params , ) return profiler . Nested ( prof , request ) except Exception : _logger . exception ( "Failure during Profiler creation" ) request . session . profile_session = None return request