Skip to content

Thread safety concerns with reliance on nibabel.tmpdirs.InTemporaryDirectory #1102

@jacobdr

Description

@jacobdr

I opened a similar ticket against dipy but figured it would be useful to open here as well as nibabel is the root cause...

Reading through the nibabel source code for InTemporaryDirectory its doing some quite sketchy things like:

self._pwd = os.getcwd()
os.chdir(self.name)

To support programs that are mutlithreaded -- as a lot of API server implementations are in the Python universe -- I suggest the implementation be revisited so as to not accidentally introduce race conditions into the code of consuming applications.

I can work on a reproduction but logically since Python threads share a single process and os.chdir operates at the process level, conceptually I think its obvious nibabel is making some bad assumptions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions