On this page
asyncio.iscoroutine
Prev: asyncio.IncompleteReadError | Up: asyncio | Next: asyncio.iscoroutinefunction
Rel: asyncio.AbstractEventLoop, asyncio.AbstractServer, asyncio.all_tasks, asyncio.as_completed
Ref: docs.python.org — asyncio.iscoroutine
Tags: #public #python3 #stdlib #asyncio
Import
import asyncio
from asyncio import iscoroutine
Signature & Overview
asyncio.iscoroutine(obj)
Return True if obj is a coroutine object.
Usage
import asyncio
async def fn(): return 1
coro = fn()
try:
assert asyncio.iscoroutine(coro) is True
assert asyncio.iscoroutine(fn) is False
finally:
coro.close()
Gotchas
- Close unawaited coroutines: Creating
fn()without awaiting or.close()ing it emitsRuntimeWarning: coroutine was never awaited.
REPL Inspect
from asyncio import iscoroutine
help(iscoroutine)
Linked from
Related notes
- tuts/python3/stdlib_module/asyncio/IncompleteReadError Linked here; links to this page; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/iscoroutinefunction Linked here; links to this page; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/asyncio/AbstractEventLoop Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/AbstractServer Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/all_tasks Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/as_completed Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/Barrier shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/BaseEventLoop shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/BaseProtocol shared tags: #asyncio, #stdlib