Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
docs: move psutil import into benchmark methods to avoid needing it a…
…s a dependency for doc building
  • Loading branch information
johanneskoester committed Nov 26, 2021
1 parent 6f1ff31 commit 6ffe38d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions docs/requirements.txt
Expand Up @@ -5,5 +5,4 @@ sphinx_rtd_theme
docutils
myst-parser
configargparse
appdirs
psutil
appdirs
5 changes: 3 additions & 2 deletions snakemake/benchmark.py
Expand Up @@ -11,8 +11,6 @@
import time
import threading

import psutil

from snakemake.exceptions import WorkflowError


Expand Down Expand Up @@ -192,6 +190,7 @@ class BenchmarkTimer(ScheduledPeriodicTimer):
"""Allows easy observation of a given PID for resource usage"""

def __init__(self, pid, bench_record, interval=BENCHMARK_INTERVAL):
import psutil
ScheduledPeriodicTimer.__init__(self, interval)
#: PID of observed process
self.pid = pid
Expand All @@ -203,6 +202,7 @@ def __init__(self, pid, bench_record, interval=BENCHMARK_INTERVAL):

def work(self):
"""Write statistics"""
import psutil
try:
self._update_record()
except psutil.NoSuchProcess:
Expand All @@ -212,6 +212,7 @@ def work(self):

def _update_record(self):
"""Perform the actual measurement"""
import psutil
# Memory measurements
rss, vms, uss, pss = 0, 0, 0, 0
# I/O measurements
Expand Down

0 comments on commit 6ffe38d

Please sign in to comment.