classification
Title: Hangup when using cgitb in a thread while still in import
Type: performance Stage: needs patch
Components: Interpreter Core Versions: Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: brett.cannon, hoffie
Priority: low Keywords:

Created on 2007-02-21 13:24 by hoffie, last changed 2009-04-01 18:20 by brett.cannon. This issue is now closed.

Files
File name Uploaded Description Edit
foo.py hoffie, 2007-02-21 13:24 File foo.py, part of the reproduction case as mentioned in the description
Messages (3)
msg31301 - (view) Author: hoffie (hoffie) Date: 2007-02-21 13:24
The problem is best described using example code (also see http://trac.saddi.com/flup/ticket/12#comment:3):

  * file foo.py: see attachment
  * file bar.py:
      import foo

Running foo.py directly produces the expected result (html output from cgitb), running bar.py outputs nothing as it seems to hang internally (only the thread which should print the html).
Moving all non-import into a function in foo.py and calling that function after the import in bar.py leads to the expected result, so it seems to be related to code which is executed while still in import and while using threads.
I don't think it is serious problem as it's only triggered in that unusual case.

I'm running python-2.4.4 on Gentoo Linux.
Linux tux 2.6.20-gentoo #2 PREEMPT Mon Feb 5 19:20:30 CET 2007 i686 AMD Athlon(tm) XP 2600+ AuthenticAMD GNU/Linux
msg84943 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2009-03-31 23:03
The freeze is occurring from cgitb importing from within the html
function. That is hitting the import lock that is being held in bar.
Moving the imports out of the functions to the top of the module should
fix this.
msg85063 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2009-04-01 18:20
So this issue -- as seems to happen to me at PyCon -- was deeper than I
thought. cgitb was importing in functions so that was fixed (r70956 for
2.x, r70957 for 3.x). But I also found out that _warnings.c was also
importing (r70965 for 2.x, r70966 for 3.x).

But the example still locks up thanks to re doing imports. Basically,
don't launch threads during an import, but I have done all that is
reasonable to rectify the situation.
History
Date User Action Args
2009-04-01 18:20:20brett.cannonsetstatus: open -> closed
resolution: wont fix
messages: + msg85063
2009-03-31 23:03:33brett.cannonsetpriority: normal -> low
versions: + Python 2.7, - Python 2.6
messages: + msg84943

type: performance
stage: needs patch
2009-02-11 04:15:05ajaksu2setassignee: brett.cannon
nosy: + brett.cannon
versions: + Python 2.6, - Python 2.4
2007-02-21 13:24:34hoffiecreate