Skip to content

Commit

Permalink
Checks to avoid exception based flow control, per review.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterallenwebb committed May 21, 2024
1 parent 547937a commit 91d63f0
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions core/dbt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import itertools
import json
import os
import sys
from enum import Enum
from pathlib import PosixPath, WindowsPath
from typing import (
Expand Down Expand Up @@ -392,15 +393,16 @@ def try_get_max_rss_kb() -> Optional[int]:
"""Attempts to get the high water mark for this process's memory use via
the most reliable and accurate mechanism available through the host OS.
Currently only implemented for Linux."""
try:
# On Linux, the most reliable documented mechanism for getting the RSS
# high-water-mark comes from the line confusingly labeled VmHWM in the
# /proc/self/status virtual file.
with open("/proc/self/status") as f:
for line in f:
if line.startswith("VmHWM:"):
return int(str.split(line)[1])
except Exception:
pass
if sys.platform == "linux" and os.path.isfile("/proc/self/status"):
try:
# On Linux, the most reliable documented mechanism for getting the RSS
# high-water-mark comes from the line confusingly labeled VmHWM in the
# /proc/self/status virtual file.
with open("/proc/self/status") as f:
for line in f:
if line.startswith("VmHWM:"):
return int(str.split(line)[1])
except Exception:
pass

Check warning on line 406 in core/dbt/utils.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/utils.py#L405-L406

Added lines #L405 - L406 were not covered by tests

return None

Check warning on line 408 in core/dbt/utils.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/utils.py#L408

Added line #L408 was not covered by tests

0 comments on commit 91d63f0

Please sign in to comment.