Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tempfile.TemporaryDirectory deleted after sleep in threads #88271

Closed
colasleguernic mannequin opened this issue May 10, 2021 · 3 comments
Closed

tempfile.TemporaryDirectory deleted after sleep in threads #88271

colasleguernic mannequin opened this issue May 10, 2021 · 3 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@colasleguernic
Copy link
Mannequin

colasleguernic mannequin commented May 10, 2021

BPO 44105
Files
  • test_tmpdir.py
  • mwe.py: with sleep instead of subprocess.run
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-10-15.07:15:03.422>
    created_at = <Date 2021-05-10.21:39:01.273>
    labels = ['3.7', '3.8', 'type-bug', 'library']
    title = 'tempfile.TemporaryDirectory deleted after sleep in threads'
    updated_at = <Date 2021-10-15.07:15:03.421>
    user = 'https://bugs.python.org/colasleguernic'

    bugs.python.org fields:

    activity = <Date 2021-10-15.07:15:03.421>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-10-15.07:15:03.422>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2021-05-10.21:39:01.273>
    creator = 'colas.le.guernic'
    dependencies = []
    files = ['50035', '50036']
    hgrepos = []
    issue_num = 44105
    keywords = []
    message_count = 3.0
    messages = ['393436', '393445', '393446']
    nosy_count = 1.0
    nosy_names = ['colas.le.guernic']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue44105'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @colasleguernic
    Copy link
    Mannequin Author

    colasleguernic mannequin commented May 10, 2021

    Yet another weird bug when one creates sub-processes from threads.
    I found several issues mentioning ThreadPoolExecutor and subprocess.run but I believe this one is different.

    When creating a temporary directory with tempfile.TemporaryDirectory (with or without context manager) it is sometimes deleted by a call to subprocess.run when both occurs inside a task sent to a ThreadPoolExecutor created without a context manager (that last part is very odd).

    Running the attached file on python 3.8.5 or 3.8.10 shows the issue only occurs if the executor is not created through a context manager.

    The bug does not seem to occur on python 3.9.5 or 3.10.0b1.

    Using a ProcessPoolExecutor seems to fix the issue too.

    @colasleguernic colasleguernic mannequin added 3.8 only security fixes type-bug An unexpected behavior, bug, or error stdlib Python modules in the Lib dir labels May 10, 2021
    @colasleguernic
    Copy link
    Mannequin Author

    colasleguernic mannequin commented May 11, 2021

    Actually, it has nothing to do with subprocess.run, replacing that line with sleep(random()) exhibits the same behavior.

    @colasleguernic colasleguernic mannequin changed the title tempfile.TemporaryDirectory deleted after call to subprocess.run in threads tempfile.TemporaryDirectory deleted after sleep in threads May 11, 2021
    @colasleguernic colasleguernic mannequin changed the title tempfile.TemporaryDirectory deleted after call to subprocess.run in threads tempfile.TemporaryDirectory deleted after sleep in threads May 11, 2021
    @colasleguernic colasleguernic mannequin added 3.7 (EOL) end of life labels May 11, 2021
    @colasleguernic
    Copy link
    Mannequin Author

    colasleguernic mannequin commented May 11, 2021

    I guess this will be a won't fix as python3.8 is now in security-fix only mode.
    I was misled by https://www.python.org/downloads/ that still indicates a bugfix maintenance status.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant