Skip to content

zipfile extractall is not multi-threading safe #112998

@pbsds

Description

@pbsds

Bug report

Bug description:

I ran into the following traceback when extracting multiple zipfiles into the same directory with concurrent.futures:

Traceback (most recent call last):
  File "/home/pbsds/ntnu/ifield/ifield/mldata/processing.py", line 252, in run
    res, start, end = future.result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/pbsds/ntnu/ifield/ifield/mldata/processing.py", line 290, in _run_job
    retval = job.do(pre_args=a)
  File "/home/pbsds/ntnu/ifield/ifield/mldata/processing.py", line 41, in do
    f(*a, **kw)
  File "/home/pbsds/ntnu/ifield/ifield/mldata/extract_file.py", line 21, in extract
    f.extractall(path=dest)
  File "/usr/lib/python3.10/zipfile.py", line 1647, in extractall
    self._extract_member(zipinfo, path, pwd)
  File "/usr/lib/python3.10/zipfile.py", line 1693, in _extract_member
    os.makedirs(upperdirs)
  File "/usr/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)

CPython versions tested on:

3.10

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions