Skip to content

Commit e6a7363

Browse files
committed
using dynamic import when calling cProfile
1 parent b75bf76 commit e6a7363

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

wolframclient/cli/commands/benchmark.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import absolute_import, print_function, unicode_literals
22

3-
import cProfile
43
import decimal
54
import os
65
import tempfile
@@ -12,6 +11,7 @@
1211
from wolframclient.utils.debug import timed
1312
from wolframclient.utils.encoding import force_text
1413
from wolframclient.utils.functional import first
14+
from wolframclient.utils.importutils import safe_import_string_and_call
1515

1616

1717
def repeat(el, n=1):
@@ -125,6 +125,8 @@ def report(self):
125125

126126
def handle(self, profile, **opts):
127127
if profile:
128-
cProfile.runctx("report()", {"report": self.report}, {})
128+
safe_import_string_and_call(
129+
"cProfile.runctx", "report()", {"report": self.report}, {}
130+
)
129131
else:
130132
self.report()

0 commit comments

Comments
 (0)