Merge "Catch FileNotFoundError when listing namespace PIDs"
This commit is contained in:
commit
7a2ef88686
@ -216,7 +216,7 @@ def list_ns_pids(namespace):
|
|||||||
try:
|
try:
|
||||||
ns_path = os.path.join(NETNS_RUN_DIR, namespace)
|
ns_path = os.path.join(NETNS_RUN_DIR, namespace)
|
||||||
ns_inode = os.stat(ns_path).st_ino
|
ns_inode = os.stat(ns_path).st_ino
|
||||||
except OSError:
|
except (OSError, FileNotFoundError):
|
||||||
return ns_pids
|
return ns_pids
|
||||||
|
|
||||||
for pid in os.listdir('/proc'):
|
for pid in os.listdir('/proc'):
|
||||||
@ -226,7 +226,7 @@ def list_ns_pids(namespace):
|
|||||||
pid_path = os.path.join('/proc', pid, 'ns', 'net')
|
pid_path = os.path.join('/proc', pid, 'ns', 'net')
|
||||||
if os.stat(pid_path).st_ino == ns_inode:
|
if os.stat(pid_path).st_ino == ns_inode:
|
||||||
ns_pids.append(int(pid))
|
ns_pids.append(int(pid))
|
||||||
except OSError:
|
except (OSError, FileNotFoundError):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
return ns_pids
|
return ns_pids
|
||||||
|
Loading…
Reference in New Issue
Block a user