Issue1773543

classification
Title: tempfile.mktemp() fails on Windows
Type: Severity: normal
Components: Library Versions:
Milestone:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: dgraham1980, zyasoft
Priority: normal Keywords:

Created on 2007-08-13.22:19:18 by dgraham1980, last changed 2009-03-08.07:13:28 by zyasoft.

Messages
msg1837 (view) Author: David Graham (dgraham1980) Date: 2007-08-13.22:19:18
The mktemp() method intermittently fails on Windows with this error message:
  File "...\jython\Lib\tempfile.py", line 142, in mktemp
  File "...\jython\Lib\tempfile.py", line 38, in gettempdir
  File "...\jython\Lib\tempfile.py", line 93, in _gettempdir_inner
  File "...\jython\Lib\javaos.py", line 125, in remove
OSError: [Errno 0] couldn't delete file: C:\DOCUME~1\datapal\LOCALS~1\Temp\tmptest

The comment for the _gettempdir_inner method indicates the use of a synchronized lock around the method to prevent a race condition of multiple threads trying to create and delete the same file name at the same time.  This lock works fine for a single multi-threaded jython application.  It does not work when you have 2 separate jython apps running at the same time.  One app tries to delete the tmptest file while the other is using it and you get this error.

We have patched _gettempdir_inner to append the current timestamp to the tmptest file name using time.time().  This has fixed the problem for us.

Any chance at this fix making it into the 2.2 final release?  We're using 2.2 RC3 now.

Thanks!
msg4196 (view) Author: Jim Baker (zyasoft) Date: 2009-03-08.07:13:28
As the documentation says in tempfile: "Deprecated since version 2.3:
Use mkstemp() instead." mktemp is susceptible to race conditions as
indicated by this bug.
History
Date User Action Args
2009-03-08 07:13:28zyasoftsetstatus: open -> closed
resolution: wont fix
messages: + msg4196
nosy: + zyasoft
2007-08-13 22:19:18dgraham1980create