MCPcopy Index your code
hub / github.com/RustPython/RustPython / _warn_unawaited_coroutine

Function _warn_unawaited_coroutine

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

Source from the content-addressed store, hash-verified

835
836# Private utility function called by _PyErr_WarnUnawaitedCoroutine
837def _warn_unawaited_coroutine(coro):
838 msg_lines = [
839 f"coroutine '{coro.__qualname__}' was never awaited\n"
840 ]
841 if coro.cr_origin is not None:
842 import linecache, traceback
843 def extract():
844 for filename, lineno, funcname in reversed(coro.cr_origin):
845 line = linecache.getline(filename, lineno)
846 yield (filename, lineno, funcname, line)
847 msg_lines.append("Coroutine created at (most recent call last)\n")
848 msg_lines += traceback.format_list(list(extract()))
849 msg = "".join(msg_lines).rstrip("\n")
850 # Passing source= here means that if the user happens to have tracemalloc
851 # enabled and tracking where the coroutine was created, the warning will
852 # contain that traceback. This does mean that if they have *both*
853 # coroutine origin tracking *and* tracemalloc enabled, they'll get two
854 # partially-redundant tracebacks. If we wanted to be clever we could
855 # probably detect this case and avoid it, but for now we don't bother.
856 _wm.warn(
857 msg, category=RuntimeWarning, stacklevel=2, source=coro
858 )
859
860
861def _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