Skip to content

Commit

Permalink
Merge pull request #25 from ispras/hide_co_timings
Browse files Browse the repository at this point in the history
Hide coroutine timings

This patch series hides debug messages about _time greedy_ tasks. See #24.
  • Loading branch information
BDanAnd authored Jan 15, 2020
2 parents ae7b8ed + 993815f commit ee76c84
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
8 changes: 7 additions & 1 deletion common/co_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
format_exception,
format_stack,
)
from .os_wrappers import (
ee
)


PROFILE_COTASK = ee("QDT_PROFILE_COTASK")


class FailedCallee(RuntimeError):
Expand Down Expand Up @@ -213,7 +219,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.
Expand Down
7 changes: 6 additions & 1 deletion widgets/tk_co_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
]

from common import (
ee,
CoDispatcher
)
from time import (
time
)
import sys


PROFILE_COTASK = ee("QDT_PROFILE_COTASK")


class TkCoDispatcher(CoDispatcher):
"""
The coroutine task dispatcher uses Tk.after method to spread task work
Expand All @@ -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 "
Expand Down

0 comments on commit ee76c84

Please sign in to comment.