Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6203

Re: File access denied after subprocess completion on Windows platform

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <mail@timgolden.me.uk>
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; 'python': 0.08; 'descriptor': 0.09; 'dive': 0.09; 'exception.': 0.09; 'from:addr:timgolden.me.uk': 0.09; 'from:name:tim golden': 0.09; 'message-id:@timgolden.me.uk': 0.09; 'subject:access': 0.09; 'subprocess': 0.09; 'files.': 0.10; 'win32': 0.12; 'wrote:': 0.14; 'delayed,': 0.16; 'fp.close()': 0.16; 'iirc,': 0.16; 'mean,': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'subject:subprocess': 0.16; 'traceback.': 0.16; 'workaround': 0.16; 'cc:addr:python-list': 0.17; 'issue.': 0.19; 'solution.': 0.19; 'subject:Windows': 0.20; 'header:In-Reply- To:1': 0.21; 'seems': 0.21; 'file,': 0.22; 'cc:2**0': 0.22; 'code.': 0.22; 'maybe': 0.23; 'cc:no real name:2**0': 0.23; 'clause': 0.23; 'elegant': 0.23; 'code': 0.24; 'windows': 0.26; "i'm": 0.27; '(the': 0.28; 'problem': 0.28; 'affected': 0.29; 'version': 0.29; 'bit': 0.30; 'cc:addr:python.org': 0.30; 'fact': 0.30; 'solved': 0.30; 'tjg': 0.30; 'varies': 0.30; 'machine': 0.33; 'too': 0.33; "i'll": 0.34; 'file': 0.34; "we're": 0.34; 'follows:': 0.34; 'there': 0.35; 'header:User-Agent:1': 0.35; 'actual': 0.36; 'issue': 0.37; 'something': 0.37; 'think': 0.38; 'could': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'received:192': 0.38; 'more': 0.60; 'within': 0.60; 'order': 0.62; 'opened': 0.63; 'back': 0.63; 'virus': 0.63; 'from:addr:mail': 0.65; 'cause': 0.67; 'attempted': 0.73; 'destination,': 0.84; 'to:none': 0.93
Date Wed, 25 May 2011 08:17:38 +0100
From Tim Golden <mail@timgolden.me.uk>
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10
MIME-Version 1.0
CC python-list@python.org
Subject Re: File access denied after subprocess completion on Windows platform
References <mailman.2013.1306231878.9059.python-list@python.org> <edf3e4cf-d706-4c33-949f-dac937a73bc9@z13g2000prk.googlegroups.com> <201105242017.27919.claudiu@virtuamagic.com> <201105242318.32306.claudiu@virtuamagic.com>
In-Reply-To <201105242318.32306.claudiu@virtuamagic.com>
Content-Type text/plain; charset=ISO-8859-6; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2056.1306309134.9059.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 82.94.164.166
X-Trace 1306309134 news.xs4all.nl 49041 [::ffff:82.94.164.166]:39105
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6203

Show key headers only | View raw


On 24/05/2011 21:18, Claudiu Nicolaie CISMARU wrote:
> 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.

There used to be a problem with subprocess fds being held by
a traceback. IIRC, the problem could be triggered by having
an except clause around a subprocess call within which something 
attempted to, eg,
remove one of the affected files. I'm sorry if that's a bit
of a woolly description but if you think this might be
biting you I'll dive in and look at the code. What version
of Python are you using?

(That said, the fact that the behaviour varies between faster
and slower computers makes that cause unlikely. Maybe we're
back to looking at virus checkers and the like...)

TJG

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

File access denied after subprocess completion on Windows platform Claudiu Nicolaie CISMARU <claudiu@virtuamagic.com> - 2011-05-24 13:01 +0300
  Re: File access denied after subprocess completion on Windows platform Claudiu Nicolaie CISMARU <claudiu@virtuamagic.com> - 2011-05-24 20:17 +0300
  Re: File access denied after subprocess completion on Windows platform Claudiu Nicolaie CISMARU <claudiu@virtuamagic.com> - 2011-05-24 23:18 +0300
  Re: File access denied after subprocess completion on Windows platform Terry Reedy <tjreedy@udel.edu> - 2011-05-24 18:03 -0400
  Re: File access denied after subprocess completion on Windows platform Tim Golden <mail@timgolden.me.uk> - 2011-05-25 08:17 +0100
  Re: File access denied after subprocess completion on Windows platform Claudiu Nicolaie CISMARU <claudiu@virtuamagic.com> - 2011-05-25 11:20 +0300

csiph-web