Author: Remi Meier <[email protected]>
Branch: stmgc-c4
Changeset: r66407:dc4ed04113de
Date: 2013-08-28 18:13 +0200
http://bitbucket.org/pypy/pypy/changeset/dc4ed04113de/
Log: prefix debug lines with the thread number during testing
diff --git a/rpython/rlib/debug.py b/rpython/rlib/debug.py
--- a/rpython/rlib/debug.py
+++ b/rpython/rlib/debug.py
@@ -1,4 +1,4 @@
-import sys, time
+import sys, time, thread
from rpython.rtyper.extregistry import ExtRegistryEntry
from rpython.rlib.objectmodel import we_are_translated
from rpython.rlib.rarithmetic import is_valid_int
@@ -76,10 +76,16 @@
_log = None # patched from tests to be an object of class DebugLog
# or compatible
+_thread_numbering = {}
+def _get_thread_num():
+ thid = thread.get_ident()
+ if thid not in _thread_numbering:
+ _thread_numbering[thid] = len(_thread_numbering)
+ return _thread_numbering[thid]
+
def debug_print(*args):
- for arg in args:
- print >> sys.stderr, arg,
- print >> sys.stderr
+ msg = " ".join(map(str, args))
+ sys.stderr.write("%s# %s\n" % (_get_thread_num(), msg))
if _log is not None:
_log.debug_print(*args)
@@ -108,15 +114,17 @@
def debug_start(category):
c = int(time.clock() * 100)
- print >> sys.stderr, '%s[%x] {%s%s' % (_start_colors_1, c,
- category, _stop_colors)
+ sys.stderr.write('%s%s# [%x] {%s%s\n' % (_start_colors_1,
+ _get_thread_num(), c,
+ category, _stop_colors))
if _log is not None:
_log.debug_start(category)
def debug_stop(category):
c = int(time.clock() * 100)
- print >> sys.stderr, '%s[%x] %s}%s' % (_start_colors_2, c,
- category, _stop_colors)
+ sys.stderr.write('%s%s# [%x] %s}%s\n' % (_start_colors_2,
+ _get_thread_num(), c,
+ category, _stop_colors))
if _log is not None:
_log.debug_stop(category)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit