File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 9
9
T_Retval = TypeVar ("T_Retval" )
10
10
PosArgsT = TypeVarTuple ("PosArgsT" )
11
11
12
+ # Use abandon_on_cancel if available
13
+ RUN_SYNC_AOC = (
14
+ "abandon_on_cancel" in inspect .getfullargspec (anyio .to_thread .run_sync ).kwonlyargs
15
+ )
16
+
12
17
13
18
async def run_sync (
14
19
func : Callable [[Unpack [PosArgsT ]], T_Retval ],
@@ -17,10 +22,7 @@ async def run_sync(
17
22
limiter : Union [CapacityLimiter , None ] = None ,
18
23
) -> T_Retval :
19
24
# AnyIO 4.1.0 renamed cancellable to abandon_on_cancel
20
- if (
21
- "abandon_on_cancel"
22
- in inspect .getfullargspec (anyio .to_thread .run_sync ).kwonlyargs
23
- ):
25
+ if RUN_SYNC_AOC :
24
26
return await anyio .to_thread .run_sync (
25
27
func , * args , abandon_on_cancel = abandon_on_cancel , limiter = limiter
26
28
)
You can’t perform that action at this time.
0 commit comments