MCPcopy Index your code
hub / github.com/python/cpython / _warn_unawaited_coroutine

Function _warn_unawaited_coroutine

Lib/_py_warnings.py:893–914  ·  view source on GitHub ↗
(coro)

Source from the content-addressed store, hash-verified

891
892# Private utility function called by _PyErr_WarnUnawaitedCoroutine
893def _warn_unawaited_coroutine(coro):
894 msg_lines = [
895 f"coroutine '{coro.__qualname__}' was never awaited\n"
896 ]
897 if coro.cr_origin is not None:
898 import linecache, traceback
899 def extract():
900 for filename, lineno, funcname in reversed(coro.cr_origin):
901 line = linecache.getline(filename, lineno)
902 yield (filename, lineno, funcname, line)
903 msg_lines.append("Coroutine created at (most recent call last)\n")
904 msg_lines += traceback.format_list(list(extract()))
905 msg = "".join(msg_lines).rstrip("\n")
906 # Passing source= here means that if the user happens to have tracemalloc
907 # enabled and tracking where the coroutine was created, the warning will
908 # contain that traceback. This does mean that if they have *both*
909 # coroutine origin tracking *and* tracemalloc enabled, they'll get two
910 # partially-redundant tracebacks. If we wanted to be clever we could
911 # probably detect this case and avoid it, but for now we don't bother.
912 _wm.warn(
913 msg, category=RuntimeWarning, stacklevel=2, source=coro
914 )
915
916
917def _setup_defaults():

Callers

nothing calls this directly

Calls 6

listClass · 0.85
extractFunction · 0.85
appendMethod · 0.45
rstripMethod · 0.45
joinMethod · 0.45
warnMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…