Unverified Commit c49a9ef3 authored by mvdbeek's avatar mvdbeek
Browse files

Fix seek in slurm memory check

Fixes
https://sentry.galaxyproject.org/share/issue/e196a12836fe40da83c5e9e24c4c8329/:
```
UnsupportedOperation: can't do nonzero end-relative seeks
  File "galaxy/jobs/runners/slurm.py", line 217, in __check_memory_limit
    f.seek(-2048, os.SEEK_END)
```
which has probably been broken since we moved to python 3.
parent dc145ed4
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -7,7 +7,10 @@ import time

from galaxy import model
from galaxy.jobs.runners.drmaa import DRMAAJobRunner
from galaxy.util import commands
from galaxy.util import (
    commands,
    unicodify,
)
from galaxy.util.custom_logging import get_logger

log = get_logger(__name__)
@@ -212,12 +215,12 @@ class SlurmJobRunner(DRMAAJobRunner):
        """
        try:
            log.debug("Checking %s for exceeded memory message from SLURM", efile_path)
            with open(efile_path) as f:
            with open(efile_path, "rb") as f:
                if os.path.getsize(efile_path) > 2048:
                    f.seek(-2048, os.SEEK_END)
                    f.readline()
                for line in f.readlines():
                    stripped_line = line.strip()
                    stripped_line = unicodify(line)
                    if stripped_line == SLURM_MEMORY_LIMIT_EXCEEDED_MSG:
                        return OUT_OF_MEMORY_MSG
                    elif any(_ in stripped_line for _ in SLURM_MEMORY_LIMIT_EXCEEDED_PARTIAL_WARNINGS):