Path: csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed0.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!82.197.223.103.MISMATCH!feeder3.cambriumusenet.nl!82.197.223.108.MISMATCH!feeder2.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.87.MISMATCH!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '(even': 0.05; 'intermediate': 0.07; 'socket': 0.07; 'subject:skip:s 10': 0.07; 'finished.': 0.09; 'tune': 0.09; 'blocks': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hmm.': 0.16; 'lie': 0.16; 'mkdir': 0.16; 'runs,': 0.16; 'seconds,': 0.16; 'sleep(delay)': 0.16; 'subject:issue': 0.16; 'subject:timing': 0.16; 'worst': 0.16; 'wrote:': 0.18; 'connects': 0.19; 'skip:1 30': 0.19; 'seems': 0.21; 'machine': 0.22; 'script': 0.25; 'mention': 0.26; 'required.': 0.27; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; 'message-id:@mail.gmail.com': 0.30; 'though.': 0.31; 'file': 0.32; 'quite': 0.32; 'running': 0.33; 'not.': 0.33; 'case,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'executing': 0.36; 'done': 0.36; 'so,': 0.37; 'remote': 0.38; 'skip:o 20': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; "couldn't": 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'tell': 0.60; 'break': 0.61; 'guarantee': 0.63; 'maximum': 0.63; '30,': 0.65; 'jul': 0.74; 'removal': 0.74; 'deleted?': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=W1iOnHNr6vid5zr2yB/2O5UezajMoM4BsyJ0dmy9628=; b=UF1nzZhqdN9+RnehUL7CibRE5TGtMTcN04gQQdmwmuO+xWVHGatOkD1xhnMoP53hM6 WAd84MyPKLfkQLp3jfYH7gwL/+lG57/mXw+eC1dRgDB8uLuO7RxXAJYZXj9PiDd0Gof5 0/nG6CpP5q6xQ5fEW9qtD5Maf0FHn0rqRz/j/ajaaISEZEvqIlaXluVGgrWox5QizE1C pdXSaa7Nn3pAKHDL0DbJiVLyPChE4vgsyOdY/BxFho6GrX6vlEKok1XSmxUixI0sRPkt KQSoV2wse4G8O3iR/I0cPzN+9IgZ9r5Eu/zoX4WBaZLj5l4BEndcPrkdSFD1qzTHSXZU 5DgA== MIME-Version: 1.0 X-Received: by 10.58.187.4 with SMTP id fo4mr27368123vec.55.1375190830802; Tue, 30 Jul 2013 06:27:10 -0700 (PDT) In-Reply-To: References: Date: Tue, 30 Jul 2013 14:27:10 +0100 Subject: Re: timing issue: shutil.rmtree and os.makedirs From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375190838 news.xs4all.nl 16001 [2001:888:2000:d::a6]:56861 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51556 On Tue, Jul 30, 2013 at 2:10 PM, Tim wrote: > hmm, now that you mention it, this is executing on a remote box with acce= ss to the same file system my local calling program is on. That is, there i= s a local call to an intermediate script that connects to a socket on the r= emote where the above program actually runs, but the file system is the sam= e place for both local and remote. > > But even so, since the script that does the rmtree and mkdir is running o= n the same machine (even though it's remote), I would think the mkdir could= n'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. Worst case, all you need is a quick loop at the bottom, eg: for delay in 100,300,600,1000,3000,5000,10000: if not os.path.exists(directory): break sleep(delay) That'll sleep a maximum of 20 seconds, tune as required. Of course, if there's a way to tune the FS to guarantee that the removal blocks correctly, that would be way better than sleep()! ChrisA