File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -410,12 +410,19 @@ def markcoroutinefunction(func):
410410 func ._is_coroutine_marker = _is_coroutine_marker
411411 return func
412412
413+ _agen_methods = ("__anext__" , "aclose" , "asend" , "athrow" )
414+
413415def iscoroutinefunction (obj ):
414416 """Return true if the object is a coroutine function.
415417
416418 Coroutine functions are normally defined with "async def" syntax, but may
417419 be marked via markcoroutinefunction.
418420 """
421+ #check if obj is async gen method and returns awaitable
422+ is_valid = isbuiltin (obj ) or ismethodwrapper (obj )
423+ if is_valid and isasyncgen (obj .__self__ ) and obj .__name__ in _agen_methods :
424+ return True
425+ #now regular case
419426 return _has_code_flag (obj , CO_COROUTINE ) or _has_coroutine_mark (obj )
420427
421428def isasyncgenfunction (obj ):
You can’t perform that action at this time.
0 commit comments