Skip to content

Commit

Permalink
Be more robust if child processes no longer exist
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Apr 25, 2024
1 parent 975784f commit 47ffb26
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions psrecord/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,16 @@ def monitor(pid, logfile=None, plot=None, duration=None, interval=None,
try:
current_cpu += get_percent(child)
current_mem = get_memory(child)
current_mem_real += current_mem.rss / 1024. ** 2
current_mem_virtual += current_mem.vms / 1024. ** 2
if include_io:
counters = child.io_counters()
read_count += counters.read_count
write_count += counters.write_count
read_bytes += counters.read_bytes
write_bytes += counters.write_bytes
except Exception:
continue
current_mem_real += current_mem.rss / 1024. ** 2
current_mem_virtual += current_mem.vms / 1024. ** 2
if include_io:
counters = child.io_counters()
read_count += counters.read_count
write_count += counters.write_count
read_bytes += counters.read_bytes
write_bytes += counters.write_bytes


if logfile:
Expand Down

0 comments on commit 47ffb26

Please sign in to comment.