On 1/24/2008 12:55 PM, Stefan Oblinger wrote:
> Hi Mary, Giovanni,
>
> i encountered the same problem with svnmerge.exe and tracked it down
> some while ago. I wondered that Pyinstaller left behind lots of _MEI*
> directories in the temp directory. Removing all these directories
> caused svnmerge.exe to be reliable again.
>
> Checking the code i discovered that it's indeed a timing issue. In
> line 43 of launch.c the return value of the remove() function is not
> checked. Removing the executed binary (and in succession the
> directory) fails quite often since the file handle is not yet released
> by the O/S yet. Replacing the lines
>
> 1042 else
> 1043 remove(fnm);
>
> by
>
> 1042 else if (remove(fnm))
> 1043 {
> 1044 /* spend a tick to release file handle */
> 1045 Sleep(100);
> 1046 remove(fnm);
> 1047 }
>
> turned out to fix the problem. It's just a workaround - i'm sure,
> there exists a better solution.
>
> I hope that helps.
Hi Stefan,
many thanks for the patch! At first, I couldn't believe this was the
reason for the random error about importing the "encodings" module at
startup, but it turns out you are totally right!
In fact, there were several bugs (or, let me say, error conditions that
were silently ignored instead of properly reported) that were causing
that exception. By forcing the _MEI directory number to one that already
existed, I was able to fix all those error conditions all the way up to
the first error that should have appeared (if anything): "cannot create
temporary directory" :)
Those fixed were done in r416 e r417 on the branch devoted to this bug.
You can see them online here:
http://pyinstaller.python-hosting.com/changeset/416
http://pyinstaller.python-hosting.com/changeset/417
The next steps are:
1) Rewrite the temporary directory code to use mkstemp() or a similar
safe race-free function. We really shouldn't be using the pid in 2008 to
generate a random name :)
2) Find out if there's a specific concurrency problem that causes the
cleanup() not to succeed as you found out. I think there's nothing that
can be done in general: in Windows, you can't remove a file while it's
open by some process. So, in general, if you have an antivirus or an
indexer like Google Desktop Search, you are bound to have such race
conditions. A little sleep like yours appears to be a good enough solution.
Thanks again for giving the lead for fixing this really annoying
old-standing bug!
--
Giovanni Bajo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"PyInstaller" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/PyInstaller?hl=en
-~----------~----~----~----~------~----~------~--~---