[issue4716] Python 3.0 halts on shutdown when settrace is set
Gabriel Genellina gagsl-...@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 rep...@bugs.python.org http://bugs.python.org/issue4716 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4716] Python 3.0 halts on shutdown when settrace is set
Antoine Pitrou pit...@free.fr added the comment: Thanks for the investigation! The problem has already been reported in #3618. Closing this one. -- resolution: - duplicate status: open - closed superseder: - possible deadlock in IO library (Lib/io.py) ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4716 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4716] Python 3.0 halts on shutdown when settrace is set
New submission from Fabio Zadrozny fab...@users.sourceforge.net: In Python 3.0, the interpreter will not shutdown properly after setting a tracing function and something goes into stdout. The code attached shows the problem in action: just execute it and notice how the interpreter will be kept running after the code has been executed. There are some more things that need to be considered: - If the print('here') is not called, it will shutdown - If BOTH the print('here') and the sys.settrace(None) is not called, it will NOT shutdown Note: I've marked the bug as crash because it's halting, but maybe there could be a better alternative for it... -- components: Interpreter Core files: tracing_test.py messages: 78169 nosy: fabioz severity: normal status: open title: Python 3.0 halts on shutdown when settrace is set type: crash versions: Python 3.0 Added file: http://bugs.python.org/file12422/tracing_test.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4716 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4716] Python 3.0 halts on shutdown when settrace is set
Antoine Pitrou pit...@free.fr added the comment: I haven't investigated, but in py3k print() has currently bits written in Python, which means it will get (recursively) traced when called from the trace function. It can of course have all kinds of funny implications! -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4716 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com