Skip to content

Commit e36eec0

Browse files
Linting
1 parent 10128ee commit e36eec0

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

cylc/flow/scripts/profiler.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def parse_memory_file(process: Process):
119119
if "total_rss" in line:
120120
return int(''.join(filter(str.isdigit, line)))
121121
except Exception as err:
122-
raise CylcProfilerError(err, "Unable to find memory usage data")
122+
raise CylcProfilerError(
123+
err, "Unable to find memory usage data") from err
123124

124125

125126
def parse_memory_allocated(process: Process) -> int:
@@ -155,7 +156,8 @@ def parse_cpu_file(process: Process) -> int:
155156
raise FileNotFoundError(process.cgroup_cpu_path)
156157

157158
except Exception as err:
158-
raise CylcProfilerError(err,"Unable to find cpu usage data")
159+
raise CylcProfilerError(
160+
err, "Unable to find cpu usage data") from err
159161

160162

161163
def get_cgroup_version(cgroup_location: str, cgroup_name: str) -> int:
@@ -168,7 +170,7 @@ def get_cgroup_version(cgroup_location: str, cgroup_name: str) -> int:
168170
except Exception as err:
169171
raise CylcProfilerError(
170172
err,
171-
"Cgroup not found at " + cgroup_location + cgroup_name)
173+
"Cgroup not found at " + cgroup_location + cgroup_name) from err
172174

173175

174176
def get_cgroup_name():
@@ -188,7 +190,8 @@ def get_cgroup_name():
188190
return result
189191

190192
except Exception as err:
191-
raise CylcProfilerError(err, '/proc/' + str(pid) + '/cgroup not found')
193+
raise CylcProfilerError(
194+
err, '/proc/' + str(pid) + '/cgroup not found') from err
192195

193196

194197
def get_cgroup_paths(location) -> Process:
@@ -217,8 +220,8 @@ def get_cgroup_paths(location) -> Process:
217220
)
218221
raise Exception
219222
except Exception as err:
220-
raise CylcProfilerError(err, "Unable to determine cgroup version")
221-
223+
raise CylcProfilerError(
224+
err, "Unable to determine cgroup version") from err
222225

223226

224227
def profile(_process: Process, delay, keep_looping=lambda: True):

0 commit comments

Comments
 (0)