[ python-Bugs-1431253 ] Logging hangs thread after detaching a StreamHandler's termi

SourceForge.net noreply at sourceforge.net
Tue Feb 14 07:07:50 CET 2006


Bugs item #1431253, was opened at 2006-02-13 22:07
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1431253&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: Open
Resolution: None
Priority: 5
Submitted By: Yang Zhang (yangzhang)
Assigned to: Nobody/Anonymous (nobody)
Summary: Logging hangs thread after detaching a StreamHandler's termi

Initial Comment:
Hi all,

After many hours, I think I've found a bug in the 
logging module!

If you add a (stdout) StreamHandler to a logger, then 
detach the terminal for that stdout, subsequent calls 
to log() will hang the calling thread.

To reproduce this, write the following scripts (this 
was a small test case I came up with - maybe there's 
something simpler):

$ cat tryhup.bash
#!/usr/bin/env bash
scp hup.* localhost:
ssh localhost './hup.bash ; while true ; do sleep 1 ; 
done'

$ cat hup.bash
#!/usr/bin/env bash
./hup.py &

$ cat hup.py
#!/usr/bin/env python
import time
import logging
f = file( '/tmp/hup.out', 'w' )
try:
        logging.basicConfig( filename = '/tmp/lup.out', 
filemode = 'w' )
        # XXX PROBLEM LINE BELOW
        logging.getLogger('').addHandler( logging.
StreamHandler() )
        while True:
                f.write( '-------\n' )
                f.flush()
                logging.critical( '======' )
                time.sleep(1)
finally:
        f.close()

Run ./tryhup.bash. It will sit in an idle spin. Monitor 
the files /tmp/hup.out and /tmp/lup.out. Hit Ctrl-C on 
tryhup to kill it. The python process is still running, 
but is stalled (the .out files are no longer changing).

If you remove the above labeled line, however, this 
doesn't happen.

Can anybody please acknowledge this bug? Any temporary 
workarounds to this problem? Thanks in advance for 
looking into this and for hearing me in!

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

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


More information about the Python-bugs-list mailing list