File tree Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Original file line number Diff line number Diff line change 1- import asyncio
21import inspect
32
3+ from .sync import iscoroutinefunction
4+
45
56def is_double_callable (application ):
67 """
@@ -18,10 +19,10 @@ def is_double_callable(application):
1819 if hasattr (application , "__call__" ):
1920 # We only check to see if its __call__ is a coroutine function -
2021 # if it's not, it still might be a coroutine function itself.
21- if asyncio . iscoroutinefunction (application .__call__ ):
22+ if iscoroutinefunction (application .__call__ ):
2223 return False
2324 # Non-classes we just check directly
24- return not asyncio . iscoroutinefunction (application )
25+ return not iscoroutinefunction (application )
2526
2627
2728def double_to_single_callable (application ):
Original file line number Diff line number Diff line change @@ -378,7 +378,7 @@ def __init__(
378378 self .func = func
379379 functools .update_wrapper (self , func )
380380 self ._thread_sensitive = thread_sensitive
381- self . _is_coroutine = asyncio . coroutines . _is_coroutine # type: ignore
381+ markcoroutinefunction ( self )
382382 if thread_sensitive and executor is not None :
383383 raise TypeError ("executor must not be set when thread_sensitive is True" )
384384 self ._executor = executor
Original file line number Diff line number Diff line change 1010
1111import pytest
1212
13- from asgiref .sync import ThreadSensitiveContext , async_to_sync , sync_to_async
13+ from asgiref .sync import (
14+ ThreadSensitiveContext ,
15+ async_to_sync ,
16+ iscoroutinefunction ,
17+ sync_to_async ,
18+ )
1419from asgiref .timeout import timeout
1520
1621
@@ -645,8 +650,8 @@ def test_sync_to_async_detected_as_coroutinefunction():
645650 def sync_func ():
646651 return
647652
648- assert not asyncio . iscoroutinefunction (sync_to_async )
649- assert asyncio . iscoroutinefunction (sync_to_async (sync_func ))
653+ assert not iscoroutinefunction (sync_to_async )
654+ assert iscoroutinefunction (sync_to_async (sync_func ))
650655
651656
652657async def async_process (queue ):
You can’t perform that action at this time.
0 commit comments