From 3cbd31b5f6ba17e7590b814473fe1d5bb03ac86c Mon Sep 17 00:00:00 2001 From: Efimov Vasily Date: Wed, 15 Jan 2020 17:27:54 +0300 Subject: [PATCH 1/3] CoDispatcher: do not print task profiling during normal operation Signed-off-by: Efimov Vasily --- common/co_dispatcher.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/common/co_dispatcher.py b/common/co_dispatcher.py index 79379aeb9..1ce461315 100644 --- a/common/co_dispatcher.py +++ b/common/co_dispatcher.py @@ -28,6 +28,12 @@ from six import ( StringIO ) +from .os_wrappers import ( + ee +) + + +PROFILE_COTASK = ee("QDT_PROFILE_COTASK") class FailedCallee(RuntimeError): @@ -215,7 +221,7 @@ def poll(self): ready = True ti = t1 - t0 - if ti > 0.05: + if PROFILE_COTASK and ti > 0.05: sys.stderr.write("Task %s consumed %f sec during iteration " # file:line is the line reference format supported by # Eclipse IDE Console. From ef3551687a313d37315ba3cf148938bf31e4150f Mon Sep 17 00:00:00 2001 From: Efimov Vasily Date: Wed, 15 Jan 2020 17:28:15 +0300 Subject: [PATCH 2/3] TkCoDispatcher: do not print task profiling during normal operation Signed-off-by: Efimov Vasily --- widgets/tk_co_dispatcher.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/widgets/tk_co_dispatcher.py b/widgets/tk_co_dispatcher.py index ce4d2d11b..0f2d3fc0a 100644 --- a/widgets/tk_co_dispatcher.py +++ b/widgets/tk_co_dispatcher.py @@ -3,6 +3,7 @@ ] from common import ( + ee, CoDispatcher ) from time import ( @@ -10,6 +11,10 @@ ) import sys + +PROFILE_COTASK = ee("QDT_PROFILE_COTASK") + + class TkCoDispatcher(CoDispatcher): """ The coroutine task dispatcher uses Tk.after method to spread task work @@ -31,7 +36,7 @@ def iteration(self): t0 = time() ready = CoDispatcher.iteration(self) ti = time() - t0 - if ti > 0.1: + if PROFILE_COTASK and ti > 0.1: sys.stderr.write(("Iteration consumed %f sec\n" % ti) + "Active tasks:\n " From 993815f18d62fa7333bf1c63944d6a21d2c73b09 Mon Sep 17 00:00:00 2001 From: Efimov Vasily Date: Wed, 15 Jan 2020 17:39:35 +0300 Subject: [PATCH 3/3] README: add note about `QDT_PROFILE_COTASK` Signed-off-by: Efimov Vasily --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 9576bdf4a..bf6d42383 100644 --- a/README.md +++ b/README.md @@ -793,3 +793,15 @@ For example: PYTHONPATH=".." python canvas_frame_test.py ``` + +## Development tips + +### Environment variables + +Environment variables affect operation of QDT modules and tools. +Commonly, a value is an `eval`uated Python expression which must return +a boolean. + +* `QDT_PROFILE_COTASK`: turns on messages about coroutine-like tasks + that consumed too many time between `yield`s. +* `grep` for `ee(` for other.