File tree 3 files changed +13
-7
lines changed
3 files changed +13
-7
lines changed Original file line number Diff line number Diff line change 1
- import asyncio
2
1
import inspect
3
2
3
+ from .sync import iscoroutinefunction
4
+
4
5
5
6
def is_double_callable (application ):
6
7
"""
@@ -18,10 +19,10 @@ def is_double_callable(application):
18
19
if hasattr (application , "__call__" ):
19
20
# We only check to see if its __call__ is a coroutine function -
20
21
# if it's not, it still might be a coroutine function itself.
21
- if asyncio . iscoroutinefunction (application .__call__ ):
22
+ if iscoroutinefunction (application .__call__ ):
22
23
return False
23
24
# Non-classes we just check directly
24
- return not asyncio . iscoroutinefunction (application )
25
+ return not iscoroutinefunction (application )
25
26
26
27
27
28
def double_to_single_callable (application ):
Original file line number Diff line number Diff line change @@ -378,7 +378,7 @@ def __init__(
378
378
self .func = func
379
379
functools .update_wrapper (self , func )
380
380
self ._thread_sensitive = thread_sensitive
381
- self . _is_coroutine = asyncio . coroutines . _is_coroutine # type: ignore
381
+ markcoroutinefunction ( self )
382
382
if thread_sensitive and executor is not None :
383
383
raise TypeError ("executor must not be set when thread_sensitive is True" )
384
384
self ._executor = executor
Original file line number Diff line number Diff line change 10
10
11
11
import pytest
12
12
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
+ )
14
19
from asgiref .timeout import timeout
15
20
16
21
@@ -645,8 +650,8 @@ def test_sync_to_async_detected_as_coroutinefunction():
645
650
def sync_func ():
646
651
return
647
652
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 ))
650
655
651
656
652
657
async def async_process (queue ):
You can’t perform that action at this time.
0 commit comments