Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Increase stack limit and mention truncation in debug stack dump
  • Loading branch information
pitrou committed Nov 7, 2017
commit aa6a0cfdd22a4c914afb37913e4b36116bafba64
2 changes: 1 addition & 1 deletion Lib/asyncio/coroutines.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def __del__(self):
if tb:
tb = ''.join(traceback.format_list(tb))
msg += ('\nCoroutine object created at '
'(most recent call last):\n')
'(most recent call last, maybe truncated):\n')
msg += tb.rstrip()
logger.error(msg)

Expand Down
7 changes: 3 additions & 4 deletions Lib/asyncio/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,9 @@ def extract_stack(f=None, limit=None):
if f is None:
f = sys._getframe().f_back
if limit is None:
# This is heuristically the max number of entries we're gonna pop + 1
# (we're only interested in displaying the top of stack)
# If this is too small, tests will fail.
limit = 4
# This is enough for decent debug information and puts
# a reasonable on the amount of work we have to do here.
limit = 10
stack = traceback.StackSummary.extract(traceback.walk_stack(f),
limit=limit,
lookup_lines=False)
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_asyncio/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1981,7 +1981,7 @@ def coro_noop():

regex = (r'^<CoroWrapper %s\(?\)? .* at %s:%s, .*> '
r'was never yielded from\n'
r'Coroutine object created at \(most recent call last\):\n'
r'Coroutine object created at \(most recent call last, maybe truncated\):\n'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we replace "maybe truncated" to "truncated to {} last lines"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"truncated to {DEBUG_STACK_DEPTH} frames" if I understood correctly

r'.*\n'
r' File "%s", line %s, in test_coroutine_never_yielded\n'
r' coro_noop\(\)$'
Expand Down