timing issue: shutil.rmtree and os.makedirs

Göktuğ Kayaalp goktug.kayaalp at gmail.com
Tue Jul 30 19:09:11 CEST 2013


On Jul 30, 2013 3:29 PM, "Chris Angelico" <rosuav at gmail.com> wrote:
>
> On Tue, Jul 30, 2013 at 2:10 PM, Tim <jtim.arnold at gmail.com> wrote:
> > hmm, now that you mention it, this is executing on a remote box with
access to the same file system my local calling program is on. That is,
there is a local call to an intermediate script that connects to a socket
on the remote where the above program actually runs, but the file system is
the same place for both local and remote.
> >
> > But even so, since the script that does the rmtree and mkdir is running
on the same machine (even though it's remote), I would think the mkdir
couldn't execute until the rmtree was completely finished.
>
> Hmm. What system is used for the file system sharing? I know quite a
> few of them lie about whether something's been completely done or not.
>
> Can you use inotify to tell you when the directory's been deleted?
> Seems stupid though.

Inotify is a linux thing, but there is kqueue for Free?BSD.  OP can run the
deletion procedure, wait for a NOTE_DELETE event, which would block, and
create the fresh directory afterwards.  It may require some C hacking
though, in case Python lacks a kqueue wrapper.  I think that this kind of
approach would be more sound than a check-wait-loop approach.

(I would elaborate more with pointers to appropriate documentation, but I'm
on a silly tablet, please excuse me for that.)

-gk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130730/25b24cb7/attachment.html>


More information about the Python-list mailing list