Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

tmp_config_or_cache_dir atexit cleanup fails after forks() #16677

Copy link
Copy link
Closed
@Alex-Richman

Description

@Alex-Richman
Issue body actions

Bug report

The atexit handler registered in _create_tmp_config_or_cache_dir to cleanup the newly created tmp dir is inherited by child processes. When these child processes exit the tmp dir is cleaned up while the parent process is still trying to use it.

In particular when the parent process itself exits and attempts to cleanup the dir it hits this error:

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python3.5/shutil.py", line 469, in rmtree
    orig_st = os.lstat(path)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/matplotlib-3z9ovc1y'

Code for reproduction

import os
import time
import pathlib

# Del MPLCONFIGDIR, and override pathlib.Path.home so matplotlib will call _create_tmp_config_or_cache_dir()
if("MPLCONFIGDIR" in os.environ):
    del os.environ["MPLCONFIGDIR"]
pathlib.Path.home = lambda: "/dev/null"

import matplotlib

pid = os.fork()
if(pid != 0):
    time.sleep(1) # Parent sleeps to allow child to exit first

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.