Target of spawnl holds handles to caller

2 views
Skip to first unread message

pythonista

unread,
Apr 16, 2008, 11:52:54 AM4/16/08
to PyInstaller
I want to update my software on the fly, so my Pyinstaller-packaged
python program downloads a new version, then calls
os.spawnl(os.P_NOWAIT, my-installer, my-installer)
and exits. The installer fails because it cannot delete the
executable. Using handle.exe from http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx
shows the called program has open handles to the caller:

listomaxinstall.exe pid: 1844 DELL420\phil
44: File (RW-) C:\Program Files\Listomax\Listomax.exe
CC: File (RW-) C:\Program Files\Listomax\Listomax.exe
144: File (RW-) C:\Documents and Settings\phil\Application Data
\Listomax\phil1
...etc.

Environment is Windows XP SP2. To reproduce this, package the
following 3-line python program, then attempt to delete the executable
while notepad is still open. The delete will fail.

import os
dst = r'C:\windows\system32\notepad.exe'
os.spawnl(os.P_NOWAIT, dst, dst)

For comparison, I tried spawnl from a C program; it does not have the
same problem.

I know this is somewhat obscure, and it's not a show-stopper, but if
anyone has any clues, I'd appreciate it. Thanks, Phil

Giovanni Bajo

unread,
Apr 27, 2008, 1:06:09 PM4/27/08
to PyIns...@googlegroups.com, list...@listomax.com

Some work was done on this regard a few months ago by Anton Gyllenberg
(have a look at his patches in the archives).

Basically, the trick is to have an extranal .pkg file instead of having
it attached ot the executable. Look for "append_pkg" in the manual.

This should fix your issue.
--
Giovanni Bajo
Develer S.r.l.
http://www.develer.com

pythonista

unread,
Apr 29, 2008, 8:18:29 PM4/29/08
to PyInstaller
Thanks for the suggestion. I got the latest via svn and tried it;
sure enough, I can delete the .exe, but now the .pkg file is locked!
For now, I've hacked my way round it by running Windows Explorer and
asking the user to run the selected file, so this is not a critical
issue for me.

Regards, Phil

On Apr 27, 10:06 am, Giovanni Bajo <ra...@develer.com> wrote:
> On 4/16/2008 5:52 PM, pythonista wrote:
> > I want to update my software on the fly, [snip...]
Reply all
Reply to author
Forward
0 new messages