fix: pyinstrument dependency (#16211)
This commit is contained in:
parent
c79de7abd7
commit
5a8484185b
|
|
@ -30,7 +30,7 @@ combine_as_imports = true
|
|||
include_trailing_comma = true
|
||||
line_length = 88
|
||||
known_first_party = superset
|
||||
known_third_party =alembic,apispec,backoff,bleach,cachelib,celery,click,colorama,cron_descriptor,croniter,cryptography,dateutil,deprecation,flask,flask_appbuilder,flask_babel,flask_caching,flask_compress,flask_jwt_extended,flask_login,flask_migrate,flask_sqlalchemy,flask_talisman,flask_testing,flask_wtf,freezegun,geohash,geopy,graphlib,holidays,humanize,isodate,jinja2,jwt,markdown,markupsafe,marshmallow,marshmallow_enum,msgpack,numpy,pandas,parameterized,parsedatetime,pgsanity,pkg_resources,polyline,prison,progress,pyarrow,pyhive,pyinstrument,pyparsing,pytest,pytest_mock,pytz,redis,requests,selenium,setuptools,simplejson,slack,sqlalchemy,sqlalchemy_utils,sqlparse,tabulate,typing_extensions,werkzeug,wtforms,wtforms_json,yaml
|
||||
known_third_party =alembic,apispec,backoff,bleach,cachelib,celery,click,colorama,cron_descriptor,croniter,cryptography,dateutil,deprecation,flask,flask_appbuilder,flask_babel,flask_caching,flask_compress,flask_jwt_extended,flask_login,flask_migrate,flask_sqlalchemy,flask_talisman,flask_testing,flask_wtf,freezegun,geohash,geopy,graphlib,holidays,humanize,isodate,jinja2,jwt,markdown,markupsafe,marshmallow,marshmallow_enum,msgpack,numpy,pandas,parameterized,parsedatetime,pgsanity,pkg_resources,polyline,prison,progress,pyarrow,pyhive,pyparsing,pytest,pytest_mock,pytz,redis,requests,selenium,setuptools,simplejson,slack,sqlalchemy,sqlalchemy_utils,sqlparse,tabulate,typing_extensions,werkzeug,wtforms,wtforms_json,yaml
|
||||
multi_line_output = 3
|
||||
order_by_type = false
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,13 @@
|
|||
from typing import Any, Callable
|
||||
from unittest import mock
|
||||
|
||||
from pyinstrument import Profiler
|
||||
from werkzeug.wrappers import Request, Response
|
||||
|
||||
try:
|
||||
from pyinstrument import Profiler
|
||||
except ModuleNotFoundError:
|
||||
Profiler = None
|
||||
|
||||
|
||||
class SupersetProfiler:
|
||||
"""
|
||||
|
|
@ -41,6 +45,9 @@ class SupersetProfiler:
|
|||
if request.args.get("_instrument") != "1":
|
||||
return Response.from_app(self.app, request.environ)
|
||||
|
||||
if Profiler is None:
|
||||
raise Exception("The module pyinstrument is not installed.")
|
||||
|
||||
profiler = Profiler(interval=self.interval)
|
||||
|
||||
# call original request
|
||||
|
|
|
|||
Loading…
Reference in New Issue