Skip to content

Commit 3c554a5

Browse files
committed
Merge branch 'release/0.12.1'
2 parents 0e62a59 + 34e46c5 commit 3c554a5

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

gridmap/job.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def send_error_mail(job):
508508
if job.heart_beat:
509509
body_text += "Last memory usage: {}\n".format(job.heart_beat["memory"])
510510
body_text += "Last cpu load: {}\n".format(job.heart_beat["cpu_load"][0])
511-
body_text += ("Last process state: " +
511+
body_text += ("Process was running at last check: " +
512512
"{}\n\n").format(job.heart_beat["cpu_load"][1])
513513

514514
body_text += "Host: {}\n\n".format(job.host_name)
@@ -523,10 +523,8 @@ def send_error_mail(job):
523523
msg.attach(body_msg)
524524

525525
# attach log file
526-
if job.heart_beat and os.path.exists(job.heart_beat["log_file"]):
527-
log_file_fn = job.heart_beat['log_file']
528-
with open(log_file_fn, "rb") as log_file:
529-
log_file_attachement = MIMEText(log_file.read())
526+
if job.heart_beat and "log_file" in job.heart_beat:
527+
log_file_attachement = MIMEText(job.heart_beat['log_file'])
530528
log_file_attachement.add_header('Content-Disposition', 'attachment',
531529
filename='{}_log.txt'.format(job.id))
532530
msg.attach(log_file_attachement)
@@ -602,8 +600,9 @@ def handle_resubmit(session_id, job, temp_dir='/scratch/'):
602600

603601
if job.num_resubmits < NUM_RESUBMITS:
604602
logger = logging.getLogger(__name__)
605-
logger.warning("Looks like job died an unnatural death, resubmitting" +
606-
"(previous resubmits = %i)", job.num_resubmits)
603+
logger.warning("Looks like job %s (%s) died an unnatural death, " +
604+
"resubmitting (previous resubmits = %i)", job.name,
605+
job.id, job.num_resubmits)
607606

608607
# remove node from white_list
609608
node_name = '{}@{}'.format(job.queue, job.host_name)

gridmap/runner.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,12 @@ def get_memory_usage(pid, heart_pid):
115115
"""
116116
process = psutil.Process(pid)
117117
mem_total = float(process.get_memory_info()[0])
118-
mem_total += sum(float(p.get_memory_info()[0]) for p in
119-
process.get_children(recursive=True)
120-
if process.pid != heart_pid)
118+
for p in process.get_children(recursive=True):
119+
if p.is_running() and p.pid != heart_pid:
120+
try:
121+
mem_total += float(p.get_memory_info()[0])
122+
except psutil.NoSuchProcess:
123+
continue
121124
return mem_total / (1024.0 ** 2.0)
122125

123126

@@ -139,10 +142,15 @@ def get_cpu_load(pid, heart_pid):
139142
running = process.status not in _SLEEP_STATUSES
140143
num_procs = 1
141144
for p in process.get_children(recursive=True):
142-
if p.pid != heart_pid:
143-
cpu_sum += float(p.get_cpu_percent())
144-
running = running or (p.status not in _SLEEP_STATUSES)
145-
num_procs += 1
145+
# Make sure this process hasn't exited before querying its status
146+
if p.is_running() and p.pid != heart_pid:
147+
try:
148+
cpu_sum += float(p.get_cpu_percent())
149+
running = running or (p.status not in _SLEEP_STATUSES)
150+
except psutil.NoSuchProcess:
151+
continue
152+
else:
153+
num_procs += 1
146154
return cpu_sum / num_procs, running
147155

148156

gridmap/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@
2828
:organization: ETS
2929
'''
3030

31-
__version__ = '0.12.0'
31+
__version__ = '0.12.1'
3232
VERSION = tuple(int(x) for x in __version__.split('.'))

gridmap/web.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
from gridmap.data import clean_path
4343
from gridmap.runner import _send_zmq_msg
44+
from gridmap.version import __version__
4445

4546

4647
class WebMonitor(object):
@@ -148,6 +149,8 @@ def main(argv=None):
148149
parser.add_argument('-p', '--port',
149150
help='Port for server to listen on.', type=int,
150151
default=8076)
152+
parser.add_argument('--version', action='version',
153+
version='%(prog)s {0}'.format(__version__))
151154
args = parser.parse_args(argv)
152155

153156
# Make warnings from built-in warnings module get formatted more nicely

0 commit comments

Comments
 (0)