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


Groups > comp.lang.python > #6131

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!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <claudiu@virtuamagic.com>
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 <claudiu@virtuamagic.com>
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 <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.2013.1306231878.9059.python-list@python.org> (permalink)
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

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Hello,

I have a program that uses pyside for an QT interface and a thread that 
downloads a lot of files. The thread is created with QThread object. But 
my problem I don't think it's QT related.

The thread retrieves with pycurl a file that contains a list of files 
and start to downloads them. The downloading is done as following:
- instantiate a Curl object
- open the file on local filesystem for write in binary mode (in a try 
block), with the name suffixed with .part.
- pass the description to the curl object for save.
- curl retrieve and save it. It has also a callback function that 
updates the interface, sending a QT signal to the interface.
(1) - use os.rename to rename the file with .part sufix to the final 
file.

On my interface I have 3 buttons. One of the buttons runs an .exe file. 
One button closes the interface and one is deactivated.

On the button that runs the exe I have a callback function that uses 
subprocess.Popen (for not waiting) for running a program (.exe) and 
returns. For now I configured to run calc.exe. The callback is not 
defined inside the downloader thread. It's defined globally (nor in 
QMainWindow object).

The problem appears when I close the called program (in our case 
calc.exe). The (1) part (the call of os.rename) raise an exception:

<type 'exceptions.WindowsError'>
(32, 'The process cannot access the file because it is being used by 
another process')
[Error 32] The process cannot access the file because it is being used 
by another process

Question is why? And how to avoid this issue? The same program on Linux 
works very fine (that's because Linux doesn't has this violation 
access)! If I remove (1) part the program works fine. Somehow after 
closing the spawned process (calc.exe - you see, it has nothing to do 
with a open file somewhere else) the thread losses the acces to the 
current opened file by itself.

-- 
  Claudiu Nicolaie CISMARU
  GNU GPG Key: http://claudiu.targujiu.net/key.gpg
  T: +40 755 135455
  E: claudiu@virtuamagic.com, claudiu.cismaru@gmail.com

Back to comp.lang.python | Previous | NextNext 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