diff --git a/tenacity/_asyncio.py b/tenacity/_asyncio.py index 6b24b2e1..35d7eb93 100644 --- a/tenacity/_asyncio.py +++ b/tenacity/_asyncio.py @@ -15,7 +15,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +import asyncio import sys from asyncio import sleep @@ -71,3 +71,9 @@ async def __anext__(self): await self.sleep(do) else: return do + + def wraps(self, fn): + fn = super().wraps(fn) + # Ensure wrapper is recognized as a coroutine function. + fn._is_coroutine = asyncio.coroutines._is_coroutine + return fn diff --git a/tenacity/tests/test_asyncio.py b/tenacity/tests/test_asyncio.py index 617a0ef5..f34a40af 100644 --- a/tenacity/tests/test_asyncio.py +++ b/tenacity/tests/test_asyncio.py @@ -58,6 +58,10 @@ async def test_retry(self): await _retryable_coroutine(thing) assert thing.counter == thing.count + @asynctest + async def test_iscoroutinefunction(self): + assert asyncio.iscoroutinefunction(_retryable_coroutine) + @asynctest async def test_retry_using_async_retying(self): thing = NoIOErrorAfterCount(5)