Use the errno attribute of an exception instead of indices
Obtaining the errno from an exception using e[0] is not possible in Python3. Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
This commit is contained in:
parent
02541dfb5c
commit
8e68e22757
1 changed files with 2 additions and 2 deletions
|
|
@ -355,7 +355,7 @@ class SchedulerPlugin(base.Plugin):
|
|||
return schedutils.get_affinity(pid)
|
||||
# Workaround for old python-schedutils which incorrectly raised error
|
||||
except (SystemError, OSError) as e:
|
||||
if e[0] == 3:
|
||||
if hasattr(e, "errno") and e.errno == errno.ESRCH:
|
||||
log.debug("Unable to read affinity for PID %s, the task vanished." % pid)
|
||||
return None
|
||||
log.error("unable to get affinity for PID '%s': %s" % (str(pid), e))
|
||||
|
|
@ -367,7 +367,7 @@ class SchedulerPlugin(base.Plugin):
|
|||
schedutils.set_affinity(pid, affinity)
|
||||
# Workaround for old python-schedutils which incorrectly raised error
|
||||
except (SystemError, OSError) as e:
|
||||
if e[0] == 3:
|
||||
if hasattr(e, "errno") and e.errno == errno.ESRCH:
|
||||
log.debug("Unable to set affinity for PID %s, the task vanished." % pid)
|
||||
return False
|
||||
log.error("unable to set affinity '%s' for PID '%s': %s" % (str(affinity), str(pid), e))
|
||||
|
|
|
|||
Loading…
Reference in a new issue