[ python-Bugs-1473760 ] TempFile can hang on Windows

SourceForge.net noreply at sourceforge.net
Fri Apr 21 23:26:22 CEST 2006


Bugs item #1473760, was opened at 2006-04-20 14:35
Message generated for change (Comment added) made by tim_one
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1473760&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
>Status: Closed
>Resolution: Fixed
Priority: 7
Submitted By: Tim Peters (tim_one)
Assigned to: Nobody/Anonymous (nobody)
Summary: TempFile can hang on Windows

Initial Comment:
Attached is a simple module.  If you try to import it
("import hang"), it prints "asking for temp file", and
hangs there, never returning from its call to
tempfile.TemporaryFile().  It's in fact stuck in
ntpath.py, on the "from nt import _getfullpathname"
line in function `abspath`.

Of course hang.py spawns another thread, and is hung
waiting for the import lock.  That thread isn't doing
any imports the _user_ knows about, and Python's
standard library should be coded more defensively than
this.

The symptom was reported on zodb-dev today, where
Martin Gfeller reported ZEO hanging on Windows for what
appears to be the same reason:

http://mail.zope.org/pipermail/zodb-dev/2006-April/009989.html

As it says there, it looks like this problem was
introduced (indirectly) by patch

    http://www.python.org/sf/810914

which appears to have been revision 34396 (October
2003! -- but not backported to 2.3, so nobody would
notice this before 2.4).

I haven't dug deeper than this, and don't know why
nobody noticed ZEO hanging before ;-)



----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2006-04-21 17:26

Message:
Logged In: YES 
user_id=31435

Fixed in rev 45631 on the trunk, and rev 45632 on the 2.4
branch.

Armin, I agree this could use a better approach.  I settled
for a micro-fix here because this specific one accounts for
a report of Zope Corp's ZEO hanging on Windows, and it was
an odd way to change ntpath.abspath to begin with.

Note that I added a new Lib/test/threaded_import_hangers.py
to check that tempfile.TemporaryFile and os.path.abspath
don't hang anymore, and that's designed to make it easy to
add additional tests of this kind.

----------------------------------------------------------------------

Comment By: Armin Rigo (arigo)
Date: 2006-04-21 13:22

Message:
Logged In: YES 
user_id=4771

The general problem keeps showing up again and again.
I can't find all reference (I remember more), but there
are at least the following open bugs about it:
#689895 #683658 #1175194.

It would certainly help matters if we implemented
something along the lines of putting a recursive lock on
each module object, held while this specific module is
being imported. More advanced solutions are possible
too, but possibly more disruptive compatibility-wise...

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1473760&group_id=5470


More information about the Python-bugs-list mailing list