[ python-Bugs-1431253 ] Logging hangs thread after detaching a StreamHandler's termi
SourceForge.net
noreply at sourceforge.net
Fri Feb 17 02:04:49 CET 2006
Bugs item #1431253, was opened at 2006-02-14 06:07
Message generated for change (Settings changed) made by vsajip
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: Pending
>Resolution: Works For Me
Priority: 5
Submitted By: Yang Zhang (yangzhang)
Assigned to: Vinay Sajip (vsajip)
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!
----------------------------------------------------------------------
>Comment By: Vinay Sajip (vsajip)
Date: 2006-02-17 01:04
Message:
Logged In: YES
user_id=308438
Please provide more information about your OS - I ran these
scripts on Ubuntu 5.10 and did not see the problems you
mention. The script continues to run (printing dashes to the
console), and hup.out/lup.out are also updated continuously.
Also, note that the logging module merely opens the stream
passed to the StreamHander for output, so check if in
your configuration you get a hang just doing a write to
sys.stderr.
----------------------------------------------------------------------
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