Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.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; 'anyway': 0.03; 'antivirus.': 0.07; 'ret': 0.07; 'python': 0.08; "(it's": 0.09; 'content-type:multipart/signed': 0.09; 'dive': 0.09; 'retcode': 0.09; 'subject:access': 0.09; 'subprocess': 0.09; 'files.': 0.10; 'def': 0.12; 'exception': 0.12; '30)': 0.16; 'blah': 0.16; 'content-type:application/pgp-signature': 0.16; 'curl': 0.16; 'except:': 0.16; 'filename)': 0.16; 'filename,': 0.16; 'filename:fname piece:asc': 0.16; 'filename:fname piece:signature': 0.16; 'filename:fname:signature.asc': 0.16; 'fp)': 0.16; 'fp.close()': 0.16; 'iirc,': 0.16; 'subject:subprocess': 0.16; 'traceback.': 0.16; 'issue.': 0.19; 'subject:Windows': 0.20; 'header:In-Reply-To:1': 0.21; "wasn't": 0.22; 'code.': 0.22; 'maybe': 0.23; 'clause': 0.23; 'tests.': 0.23; 'runs': 0.23; 'code': 0.24; "i'm": 0.27; 'raise': 0.28; 'problem': 0.28; 'affected': 0.29; 'problema': 0.29; 'instead': 0.29; 'version': 0.29; 'bit': 0.30; 'fact': 0.30; 'disabled': 0.30; 'sleep': 0.30; 'url:key': 0.30; 'varies': 0.30; "didn't": 0.31; 'print': 0.31; 'done': 0.32; 'yet': 0.32; 'to:addr:python- list': 0.33; 'machine': 0.33; '...': 0.34; "i'll": 0.34; 'file': 0.34; "we're": 0.34; 'there': 0.35; 'header:User-Agent:1': 0.35; 'gnu': 0.35; 'try:': 0.35; 'skip:o 20': 0.37; 'something': 0.37; 'hack': 0.37; 'think': 0.38; 'could': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'skip:s 20': 0.39; 'to:addr:python.org': 0.39; 'more': 0.60; 'within': 0.60; 'header:Message-Id:1': 0.62; 'closed': 0.62; 'back': 0.63; 'url:net': 0.63; 'virus': 0.63; 'cause': 0.67; 'header:Reply-To:1': 0.72; 'reply-to:no real name:2**0': 0.72; 'attempted': 0.73; '"":': 0.84; ':).': 0.84; 'catches': 0.84; 'ugly,': 0.84 From: Claudiu Nicolaie CISMARU Organization: virtuaMAGIC To: python-list@python.org Subject: Re: File access denied after subprocess completion on Windows platform Date: Wed, 25 May 2011 11:20:45 +0300 User-Agent: KMail/1.13.7 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.3; i686; ; ) References: <201105242318.32306.claudiu@virtuamagic.com> <4DDCAD12.4050203@timgolden.me.uk> In-Reply-To: <4DDCAD12.4050203@timgolden.me.uk> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1417754.9mQuc9Cu1C"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: claudiu@virtuamagic.com 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: 123 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1306311652 news.xs4all.nl 49181 [::ffff:82.94.164.166]:57792 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6209 --nextPart1417754.9mQuc9Cu1C Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable > 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=20 > attempted to, eg, > remove one of the affected files. I have no subprocess call.. in this last issue. And I didn't triggered=20 one (disabled the Button that runs the subprocess). try: for line in t.splitlines(): [...] ret =3D self.downloadFileToDisk(filename, do_rename) if not ret: print "DEBUG: Problema la download" raise Exception() (1) except Exception as inst: print type(inst) print inst.args self.updateText.emit("EROARE: Eroare la descarcare") self.updateStatusBar.emit("EROARE: Eroare la descaracare=20 fisiere") return Where downloadFileToDisk(): def downloadFileToDisk(self, filename, final_rename=3DTrue): dfilename =3D os.path.join(saveBasePATH, filename) sfilename =3D dfilename + ".part" dfolder =3D os.path.dirname(sfilename) if dfolder !=3D "": if not os.path.isdir(dfolder): os.makedirs(dfolder) try: fp =3D open(sfilename, "wb") except: return False curl =3D pycurl.Curl() curl.setopt(pycurl.URL, baseUpdateURL + "/client/" + filename) curl.setopt(pycurl.CONNECTTIMEOUT, 30) curl.setopt(pycurl.NOPROGRESS, 0) curl.setopt(pycurl.FOLLOWLOCATION, 1) curl.setopt(pycurl.MAXREDIRS, 5) curl.setopt(pycurl.PROGRESSFUNCTION, self.updateFileProgress) curl.setopt(pycurl.WRITEDATA, fp) curl.setopt(pycurl.BUFFERSIZE, 4194304) curl.setopt(pycurl.NOSIGNAL, 1) curl.perform() retcode =3D curl.getinfo(pycurl.HTTP_CODE) curl.close() fp.close() if retcode !=3D 200: (2) os.unlink(sfilename) return False self.msleep(10) if final_rename: os.rename(sfilename, dfilename) return True Without self.msleep(10), (1) catches WindowsError: file access ... blah=20 blah. Maybe at (2) can be an access violation, but it wasn't triggered=20 yet in tests. I will move the sleep after fp.close(). Yes, I know that=20 what it've done with raise Exception() is UGLY, since this program it's=20 more a quick hack solution to a problem :). Anyway the Exception that is=20 catched is not rised by my code (it's a WindowsError).=20 > 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? Last 2.7.x. Well, if os.rename is instead a subprocess call, then it's=20 subprocess based. I'm new to Python but 99% I think it's a system call=20 :) > (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...) On that virtual machine there is no virus checker. On the faster machine=20 I disabled and closed the antivirus. =2D-=20 Claudiu Nicolaie CISMARU GNU GPG Key: http://claudiu.targujiu.net/key.gpg T: +40 755 135455 E: claudiu@virtuamagic.com, claudiu.cismaru@gmail.com --nextPart1417754.9mQuc9Cu1C Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) iEYEABECAAYFAk3cu98ACgkQhU2qCxfP7CorqACg8BXUtXsad6PfvulC6WX9w7tQ 6s4Ani3pwYRR4nGrjTRPatywPV60imyX =yjTq -----END PGP SIGNATURE----- --nextPart1417754.9mQuc9Cu1C--