Skip to content

Commit

Permalink
Merge branch 'release_16.04' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Jun 2, 2016
2 parents ec476c7 + 58f3f5c commit 84ece6d
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions lib/galaxy/jobs/runners/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
SLURM job control via the DRMAA API.
"""

import os
import time
import logging
import subprocess
Expand All @@ -16,6 +17,7 @@
SLURM_MEMORY_LIMIT_EXCEEDED_MSG = 'slurmstepd: error: Exceeded job memory limit'
SLURM_MEMORY_LIMIT_EXCEEDED_PARTIAL_WARNINGS = [': Exceeded job memory limit at some point.',
': Exceeded step memory limit at some point.']
SLURM_MEMORY_LIMIT_SCAN_SIZE = 16 * 1024 * 1024 # 16MB


class SlurmJobRunner( DRMAAJobRunner ):
Expand Down Expand Up @@ -88,8 +90,12 @@ def __get_jobinfo():
return
if drmaa_state == self.drmaa_job_states.DONE:
with open(ajs.error_file, 'r+') as f:
if os.path.getsize(ajs.error_file) > SLURM_MEMORY_LIMIT_SCAN_SIZE:
f.seek(-SLURM_MEMORY_LIMIT_SCAN_SIZE, os.SEEK_END)
f.readline()
pos = f.tell()
lines = f.readlines()
f.seek(0)
f.seek(pos)
for line in lines:
stripped_line = line.strip()
if any([_ in stripped_line for _ in SLURM_MEMORY_LIMIT_EXCEEDED_PARTIAL_WARNINGS]):
Expand All @@ -110,21 +116,12 @@ def __check_memory_limit( self, efile_path ):
try:
log.debug( 'Checking %s for exceeded memory message from slurm', efile_path )
with open( efile_path ) as f:
pos = 2
bof = False
while pos < 2048:
try:
f.seek(-pos, 2)
pos += 1
except:
f.seek(-pos + 1, 2)
bof = True

if (bof or f.read(1) == '\n') and f.readline().strip() == SLURM_MEMORY_LIMIT_EXCEEDED_MSG:
if os.path.getsize(efile_path) > 2048:
f.seek(-2048, os.SEEK_END)
f.readline()
for line in f.readlines():
if line.strip() == SLURM_MEMORY_LIMIT_EXCEEDED_MSG:
return True

if bof:
break
except:
log.exception('Error reading end of %s:', efile_path)

Expand Down

0 comments on commit 84ece6d

Please sign in to comment.