From 4ba7285608ecc5864d6aec4820ae668b0c00a220 Mon Sep 17 00:00:00 2001 From: Riccardo Murri Date: Wed, 30 Aug 2017 21:59:08 +0200 Subject: [PATCH] Fix error "Cannot add 'Memory' to 'NoneType'" when running tasks with no memory requirement. --- gc3libs/backends/shellcmd.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gc3libs/backends/shellcmd.py b/gc3libs/backends/shellcmd.py index f160037a..4a7d4f1b 100755 --- a/gc3libs/backends/shellcmd.py +++ b/gc3libs/backends/shellcmd.py @@ -882,9 +882,19 @@ def count_used_memory(self): Similar caveats as in `ShellcmdLrms.count_running_tasks`:meth: apply here. """ - return sum((info['requested_memory'] - for info in self._job_infos.values() - if not info['terminated']), 0*MB) + return sum( + # FIXME: if `requested_memory==None` then just do not + # account a task's memory usage. This is of course + # incorrect and leads to situations where a single task + # can wreak havoc on an entire compute node, but is + # consistent with what we do during scheduling / + # requirements check. (OTOH, it's *not* consistent with + # what other backends do: SLURM, for example, takes the + # pessimistic stance that a job with no memory + # requirements is using (DefMemPerCPU * NumCPUs) + ((info['requested_memory'] or 0*MB) + for info in self._job_infos.values() + if not info['terminated']), 0*MB) def _get_persisted_job_info(self):