Skip to content

Commit 783b76c

Browse files
committed
remove deprecated asyncio.iscoroutine* usage
1 parent 2448c78 commit 783b76c

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

reflex/state.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def __call__(self, *args: Any) -> EventSpec:
246246
msg = f"Variable `{args[0]}` cannot be set on `{self.state_cls.get_full_name()}`"
247247
raise AttributeError(msg)
248248

249-
if asyncio.iscoroutinefunction(handler.fn):
249+
if inspect.iscoroutinefunction(handler.fn):
250250
msg = f"Setter for {args[0]} is async, which is not supported."
251251
raise NotImplementedError(msg)
252252

@@ -287,7 +287,7 @@ async def _resolve_delta(delta: Delta) -> Delta:
287287
tasks = {}
288288
for state_name, state_delta in delta.items():
289289
for var_name, value in state_delta.items():
290-
if asyncio.iscoroutine(value):
290+
if inspect.iscoroutine(value):
291291
tasks[state_name, var_name] = asyncio.create_task(
292292
value,
293293
name=f"reflex_resolve_delta|{state_name}|{var_name}|{time.time()}",
@@ -1733,7 +1733,7 @@ def _is_valid_type(events: Any) -> bool:
17331733
except TypeError:
17341734
pass
17351735

1736-
coroutines = [e for e in events if asyncio.iscoroutine(e)]
1736+
coroutines = [e for e in events if inspect.iscoroutine(e)]
17371737

17381738
for coroutine in coroutines:
17391739
coroutine_name = coroutine.__qualname__
@@ -1895,7 +1895,7 @@ async def _process_event(
18951895
# Wrap the function in a try/except block.
18961896
try:
18971897
# Handle async functions.
1898-
if asyncio.iscoroutinefunction(fn.func):
1898+
if inspect.iscoroutinefunction(fn.func):
18991899
events = await fn(**payload)
19001900

19011901
# Handle regular functions.

reflex/utils/misc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import asyncio
44
import contextlib
5+
import inspect
56
import sys
67
import threading
78
from collections.abc import Callable
@@ -62,7 +63,7 @@ async def run_in_thread(func: Callable) -> Any:
6263
Returns:
6364
Any: The return value of the function.
6465
"""
65-
if asyncio.coroutines.iscoroutinefunction(func):
66+
if inspect.iscoroutinefunction(func):
6667
msg = "func must be a non-async function"
6768
raise ValueError(msg)
6869
return await asyncio.get_event_loop().run_in_executor(None, func)

reflex/utils/monitoring.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""PyLeak integration for monitoring event loop blocking and resource leaks in Reflex applications."""
22

3-
import asyncio
43
import contextlib
54
import functools
65
import inspect
@@ -154,7 +153,7 @@ async def async_gen_wrapper(*args, **kwargs):
154153

155154
return async_gen_wrapper
156155

157-
if asyncio.iscoroutinefunction(func):
156+
if inspect.iscoroutinefunction(func):
158157

159158
@functools.wraps(func)
160159
async def async_wrapper(*args, **kwargs):

0 commit comments

Comments
 (0)