Skip to content

Commit fde9234

Browse files
committed
Using has_psutil
1 parent 5f3906a commit fde9234

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

memory_profiler.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,13 +437,12 @@ def memory_usage(*args, **kwargs):
437437
return memory_usage_actual(*args, **kwargs)
438438
except Exception:
439439
print(traceback.format_exc(), file=sys.stderr)
440-
try: # catch ImportError for psutil
441-
import psutil
440+
if has_psutil:
442441
parent = psutil.Process(os.getpid())
443442
for child in parent.children(recursive=True):
444443
os.kill(child.pid, SIGKILL)
445444
os.kill(os.getpid(), SIGKILL)
446-
except ImportError:
445+
else:
447446
sys.exit()
448447

449448

0 commit comments

Comments
 (0)