summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/coroutines.py
diff options
context:
space:
mode:
authorAntoine Pitrou <pitrou@free.fr>2017-11-07 16:23:29 (GMT)
committerGitHub <noreply@github.com>2017-11-07 16:23:29 (GMT)
commit921e9432a1461bbf312c9c6dcc2b916be6c05fa0 (patch)
treefe7133dd95ad4d039de908df4af3bc71ef1f0bc8 /Lib/asyncio/coroutines.py
parent1e5d54cfa031f1de9ee2d2e968e0551b6e2397b7 (diff)
downloadcpython-921e9432a1461bbf312c9c6dcc2b916be6c05fa0.zip
cpython-921e9432a1461bbf312c9c6dcc2b916be6c05fa0.tar.gz
cpython-921e9432a1461bbf312c9c6dcc2b916be6c05fa0.tar.bz2
bpo-31970: Reduce performance overhead of asyncio debug mode. (#4314)
* bpo-31970: Reduce performance overhead of asyncio debug mode.
Diffstat (limited to 'Lib/asyncio/coroutines.py')
-rw-r--r--Lib/asyncio/coroutines.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/asyncio/coroutines.py b/Lib/asyncio/coroutines.py
index b2adaad..520a309 100644
--- a/Lib/asyncio/coroutines.py
+++ b/Lib/asyncio/coroutines.py
@@ -10,6 +10,7 @@ import traceback
import types
from . import compat
+from . import constants
from . import events
from . import base_futures
from .log import logger
@@ -91,7 +92,7 @@ class CoroWrapper:
assert inspect.isgenerator(gen) or inspect.iscoroutine(gen), gen
self.gen = gen
self.func = func # Used to unwrap @coroutine decorator
- self._source_traceback = traceback.extract_stack(sys._getframe(1))
+ self._source_traceback = events.extract_stack(sys._getframe(1))
self.__name__ = getattr(gen, '__name__', None)
self.__qualname__ = getattr(gen, '__qualname__', None)
@@ -183,8 +184,9 @@ class CoroWrapper:
tb = getattr(self, '_source_traceback', ())
if tb:
tb = ''.join(traceback.format_list(tb))
- msg += ('\nCoroutine object created at '
- '(most recent call last):\n')
+ msg += (f'\nCoroutine object created at '
+ f'(most recent call last, truncated to '
+ f'{constants.DEBUG_STACK_DEPTH} last lines):\n')
msg += tb.rstrip()
logger.error(msg)