Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'content- type:multipart/signed': 0.09; 'exception:': 0.09; 'issue?': 0.09; 'object.': 0.09; 'rename': 0.09; 'subject:access': 0.09; 'files.': 0.10; 'linux': 0.11; 'binary': 0.14; 'defined': 0.14; 'block),': 0.16; 'buttons': 0.16; 'callback': 0.16; 'closes': 0.16; 'content- type:application/pgp-signature': 0.16; 'curl': 0.16; 'exe': 0.16; 'filename:fname piece:asc': 0.16; 'filename:fname piece:signature': 0.16; 'filename:fname:signature.asc': 0.16; 'filesystem': 0.16; 'instantiate': 0.16; 'object).': 0.16; 'retrieves': 0.16; 'subject:subprocess': 0.16; 'thread.': 0.16; 'somewhere': 0.17; 'subject:Windows': 0.20; 'interface': 0.21; 'appears': 0.21; 'fine': 0.22; 'globally': 0.23; 'somehow': 0.23; 'runs': 0.23; "doesn't": 0.25; 'function': 0.25; '(in': 0.26; 'object': 0.26; 'pass': 0.27; '(the': 0.28; 'raise': 0.28; 'problem': 0.28; 'closing': 0.28; 'mode': 0.29; 'fine.': 0.29; 'interface.': 0.29; 'see,': 0.30; 'url:key': 0.30; 'it.': 0.31; 'done': 0.32; 'configured': 0.32; 'downloads': 0.32; 'file.': 0.32; 'to:addr:python-list': 0.33; 'list': 0.33; '(for': 0.33; 'question': 0.34; 'file': 0.34; 'header:User-Agent:1': 0.35; 'gnu': 0.35; 'charset:us-ascii': 0.36; 'open': 0.36; 'uses': 0.36; 'created': 0.36; 'running': 0.37; 'thread': 0.37; 'case': 0.37; 'another': 0.37; 'think': 0.38; 'hello,': 0.38; 'run': 0.38; 'but': 0.38; 'signal': 0.38; 'called': 0.39; 'itself.': 0.39; 'to:addr:python.org': 0.39; 'current': 0.40; 'following:': 0.40; 'final': 0.60; 'header:Message-Id:1': 0.62; 'opened': 0.63; 'url:net': 0.63; 'our': 0.63; 'violation': 0.67; 'header:Reply- To:1': 0.72; 'reply-to:no real name:2**0': 0.72; 'why?': 0.73; 'deactivated.': 0.84; 'returns.': 0.84; 'losses': 0.91 From: Claudiu Nicolaie CISMARU Organization: virtuaMAGIC To: python-list@python.org Subject: File access denied after subprocess completion on Windows platform Date: Tue, 24 May 2011 13:01:24 +0300 User-Agent: KMail/1.13.7 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.3; i686; ; ) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart21780649.iCygRZHF8Y"; 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: 67 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1306231879 news.xs4all.nl 49045 [::ffff:82.94.164.166]:37874 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6131 --nextPart21780649.iCygRZHF8Y Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, I have a program that uses pyside for an QT interface and a thread that=20 downloads a lot of files. The thread is created with QThread object. But=20 my problem I don't think it's QT related. The thread retrieves with pycurl a file that contains a list of files=20 and start to downloads them. The downloading is done as following: =2D instantiate a Curl object =2D open the file on local filesystem for write in binary mode (in a try=20 block), with the name suffixed with .part. =2D pass the description to the curl object for save. =2D curl retrieve and save it. It has also a callback function that=20 updates the interface, sending a QT signal to the interface. (1) - use os.rename to rename the file with .part sufix to the final=20 file. On my interface I have 3 buttons. One of the buttons runs an .exe file.=20 One button closes the interface and one is deactivated. On the button that runs the exe I have a callback function that uses=20 subprocess.Popen (for not waiting) for running a program (.exe) and=20 returns. For now I configured to run calc.exe. The callback is not=20 defined inside the downloader thread. It's defined globally (nor in=20 QMainWindow object). The problem appears when I close the called program (in our case=20 calc.exe). The (1) part (the call of os.rename) raise an exception: (32, 'The process cannot access the file because it is being used by=20 another process') [Error 32] The process cannot access the file because it is being used=20 by another process Question is why? And how to avoid this issue? The same program on Linux=20 works very fine (that's because Linux doesn't has this violation=20 access)! If I remove (1) part the program works fine. Somehow after=20 closing the spawned process (calc.exe - you see, it has nothing to do=20 with a open file somewhere else) the thread losses the acces to the=20 current opened file by itself. =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 --nextPart21780649.iCygRZHF8Y 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) iEYEABECAAYFAk3bgfgACgkQhU2qCxfP7CrPPgCfWDXbBKZkS6M2WGcGyMG8Vkfi SiYAn2Rmjty2ydRfp8qBe4F/EP/5TsyB =Fc3a -----END PGP SIGNATURE----- --nextPart21780649.iCygRZHF8Y--