Logging hangs thread after detaching a StreamHandler's terminal

Vinay Sajip vinay_sajip at yahoo.co.uk
Tue Feb 14 06:29:45 EST 2006


python-list.overbored at spamgourmet.com wrote:
> 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):
>
[scripts snipped]
> 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!

I tried these scripts on Ubuntu 5.10 and did not see the problem you
are experiencing. The script continues to run (printing dashes to the
console), and hup.out/lup.out are also updated continuously.

What's your configuration? 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.

Best regards,

Vinay Sajip




More information about the Python-list mailing list