Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'terry': 0.07; 'descriptor': 0.09; 'exception.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:access': 0.09; 'pm,': 0.10; 'win32': 0.12; 'wrote:': 0.14; 'delayed,': 0.16; 'fp.close()': 0.16; 'mean,': 0.16; 'mysterious': 0.16; 'reedy': 0.16; 'subject:subprocess': 0.16; 'workaround': 0.16; 'issue.': 0.19; 'solution.': 0.19; 'jan': 0.20; 'subject:Windows': 0.20; 'header:In-Reply-To:1': 0.21; 'appears': 0.21; 'seems': 0.21; 'file,': 0.22; 'elegant': 0.23; 'works.': 0.23; 'code': 0.24; 'windows': 0.26; '(the': 0.28; 'random': 0.28; 'seemingly': 0.30; 'solved': 0.30; 'header:X-Complaints-To:1': 0.32; 'to:addr:python- list': 0.33; 'experience,': 0.33; 'machine': 0.33; 'too': 0.33; 'error': 0.33; 'file': 0.34; 'follows:': 0.34; 'there': 0.35; 'header:User-Agent:1': 0.35; 'actual': 0.36; 'issue': 0.37; 'thread': 0.37; 'think': 0.38; 'received:org': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'windows.': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'more': 0.60; 'order': 0.62; 'opened': 0.63; 'night': 0.77; 'destination,': 0.84; 'trick.': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: File access denied after subprocess completion on Windows platform Date: Tue, 24 May 2011 18:03:42 -0400 References: <201105242017.27919.claudiu@virtuamagic.com> <201105242318.32306.claudiu@virtuamagic.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-6; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: rain.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 In-Reply-To: <201105242318.32306.claudiu@virtuamagic.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 32 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1306274632 news.xs4all.nl 49183 [::ffff:82.94.164.166]:35960 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6179 On 5/24/2011 4:18 PM, Claudiu Nicolaie CISMARU wrote: >> Seems that close_fds did the trick. Anyway, I read that description on >> the documentation last night but I think I was so tired that I >> understood that in Windows has no effect... :) > > Now. There is one more issue. Seems that on faster computers and/or > Windows 7 (the Win32 thing I have tested on a HVM Xen machine with > Windows XP) the os.rename is too fast after fp.close() and generates the > same Exception. The code follows: > > curl.close() > fp.close() > os.rename(tfile, actualfile) > > Where, tfile is the .part file, actual file is the real destination, fp > was opened with open(..., "wb") and the descriptor passed to curl. > > I have solved the issue with self.msleep(10) - msleep is a method of > QThread. But I don't think it's an elegant and normal solution. Did > fp.close() is delayed, or? I mean, I don't want to rely on a "sleep" in > order to workaround the access issue. > > On this issue there is no more process spawn, nothing, just the > downloader thread and the main window. And the access denied appears at > random time. I would go with what works. In my experience, mysterious and seemingly buggy error messages, including Access Denied are not unusual on Windows. -- Terry Jan Reedy