[issue4716] Python 3.0 halts on shutdown when settrace is set

Gabriel Genellina report at bugs.python.org
Sat Dec 27 00:03:23 CET 2008


Gabriel Genellina <gagsl-py2 at yahoo.com.ar> added the comment:

Yes, this is exactly the problem. The execution never goes beyond print
('here'); if you print frame.f_lineno you'll see it blocks at io.py 
line 1036, waiting for a Lock for the second time.

So the trace function cannot use print, not write to regular files 
(because io.py is written in Python). This is a severe limitation.

As a workaround, you can use the _fileio module (written in C):

import _fileio
f = _fileio._FileIO("output.txt", "w", True)

def tracing_func(frame, event, arg):
    f.write('%s %s %d\n' % (frame.f_code.co_filename, frame.f_code.co_
name, frame.f_lineno))
    return tracing_func

A possible fix would be to use an RLock instead of a Lock object, but 
I haven't investigated it.

----------
components: +Library (Lib)
nosy: +gagenellina

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4716>
_______________________________________


More information about the Python-bugs-list mailing list