Commit 02a190aa authored by Leo Le Bouter's avatar Leo Le Bouter

do not follow symlinks in getxattr, close mp_pool first

multiprocessing.Pool.close() ensures no new tasks can be submitted
to the pool and waits for them to all finish. Even though
AsyncResult.get() also waits for the tasks to finish, and our code
structure shouldnt submit new tasks at that point, close() first,
get() then. In the future this could be error-prone in the future
where mp_tasks is modified while results are being merged back and
we miss some results because the iterator wont take these new items
into account *during* iteration.
parent 16acbcbc
......@@ -76,7 +76,7 @@ def construct_fs_tree(mp_pool=None, mp_tasks=[], cur_dict=None, path="/", dev_wh
cur_dict["childs"][entry_name]["xattrs"] = dict()
for k in os.listxattr(entry_path, follow_symlinks=False):
cur_dict["childs"][entry_name]["xattrs"][k] = codecs.decode(
os.getxattr(entry_path, k), "utf-8")
os.getxattr(entry_path, k, follow_symlinks=False), "utf-8")
except Exception:
traceback.print_exc()
......@@ -104,6 +104,8 @@ def construct_fs_tree(mp_pool=None, mp_tasks=[], cur_dict=None, path="/", dev_wh
traceback.print_exc()
if is_first_call == True:
mp_pool.close()
for task in mp_tasks:
try:
result = task["result"].get()
......@@ -113,7 +115,6 @@ def construct_fs_tree(mp_pool=None, mp_tasks=[], cur_dict=None, path="/", dev_wh
except Exception:
traceback.print_exc()
mp_pool.close()
mp_pool.join()
return cur_dict
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment