Skip to content

Add to shutil the ability to wait until files are definitely deleted #66223

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

Open
zware opened this issue Jul 21, 2014 · 8 comments
Open

Add to shutil the ability to wait until files are definitely deleted #66223

zware opened this issue Jul 21, 2014 · 8 comments
Labels
OS-windows stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@zware
Copy link
Member

zware commented Jul 21, 2014

BPO 22024
Nosy @loewis, @rhettinger, @vstinner, @jkloth, @ezio-melotti, @zware, @serhiy-storchaka, @seanmccully
Files
  • shutil_wait.patch
  • issue22024.patch: Adds _shutil.c and wait_until_deleted method
  • 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 = None
    created_at = <Date 2014-07-21.20:00:08.529>
    labels = ['easy', 'type-feature', 'library']
    title = 'Add to shutil the ability to wait until files are definitely deleted'
    updated_at = <Date 2019-07-29.11:35:02.713>
    user = 'https://github.com/zware'

    bugs.python.org fields:

    activity = <Date 2019-07-29.11:35:02.713>
    actor = 'vstinner'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2014-07-21.20:00:08.529>
    creator = 'zach.ware'
    dependencies = []
    files = ['36213', '36433']
    hgrepos = []
    issue_num = 22024
    keywords = ['patch', 'easy']
    message_count = 8.0
    messages = ['223604', '224565', '224566', '224569', '224572', '224592', '225645', '348621']
    nosy_count = 9.0
    nosy_names = ['loewis', 'rhettinger', 'vstinner', 'jkloth', 'ezio.melotti', 'zach.ware', 'serhiy.storchaka', 'Vivek.Balakrishnan', 'seanmccully']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'needs patch'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue22024'
    versions = ['Python 3.5']

    @zware
    Copy link
    Member Author

    zware commented Jul 21, 2014

    As suggested by Martin in msg170717, shutil should grow some way to block until a given file/directory is actually deleted, due to Windows' scheme of not actually deleting a file until all handles to it are closed.

    This could take the form of a 'wait=False' parameter to rmtree that causes rmtree to block until the file/dir is gone (which could mean blocking indefinitely), or a new function "wait_until_deleted(name, timeout=None)".

    Related issues: bpo-15946, bpo-7443, bpo-19629

    @zware zware added stdlib Python modules in the Lib dir easy type-feature A feature request or enhancement labels Jul 21, 2014
    @VivekBalakrishnan
    Copy link
    Mannequin

    VivekBalakrishnan mannequin commented Aug 2, 2014

    Patch that adds wait parameter to shutil.rmtree.

    @serhiy-storchaka
    Copy link
    Member

    What if other program will create a file with same name in short time after deletion? Then rmtree() will hang in infinity loop.

    @VivekBalakrishnan
    Copy link
    Mannequin

    VivekBalakrishnan mannequin commented Aug 2, 2014

    With respect to msg224566, is a default timeout a good solution?

    @serhiy-storchaka
    Copy link
    Member

    On Linux and some other systems there is an API which allow you to subscribe
    on notifications about file system events (in particular on deleting specified
    file). There are modules which provides Python interface to it (e.g. python-
    inotify, inotifyx, pyinotify). May be there is similar API on Windows?

    @rhettinger
    Copy link
    Contributor

    @seanmccully
    Copy link
    Mannequin

    seanmccully mannequin commented Aug 22, 2014

    Is this closer to what Zachary.Ware suggested, patch implements a wait_until_deleted method in C Api using inotify for Linux/FreeBSD.

    @vstinner
    Copy link
    Member

    This issue is 5 years old and has 2 patches: it's far from being "newcomer friendly", I remove the "Easy" label.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    OS-windows stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants