add run_in_thread (#3077)
This commit is contained in:
parent
4056ad613f
commit
e377ce70b6
@ -6,6 +6,7 @@ omit =
|
|||||||
reflex/__main__.py
|
reflex/__main__.py
|
||||||
reflex/app_module_for_backend.py
|
reflex/app_module_for_backend.py
|
||||||
reflex/components/chakra/*
|
reflex/components/chakra/*
|
||||||
|
reflex/experimental/*
|
||||||
|
|
||||||
[report]
|
[report]
|
||||||
show_missing = true
|
show_missing = true
|
||||||
|
@ -4,6 +4,7 @@ from types import SimpleNamespace
|
|||||||
|
|
||||||
from ..utils.console import warn
|
from ..utils.console import warn
|
||||||
from . import hooks as hooks
|
from . import hooks as hooks
|
||||||
|
from .misc import run_in_thread as run_in_thread
|
||||||
|
|
||||||
warn(
|
warn(
|
||||||
"`rx._x` contains experimental features and might be removed at any time in the future .",
|
"`rx._x` contains experimental features and might be removed at any time in the future .",
|
||||||
@ -11,4 +12,5 @@ warn(
|
|||||||
|
|
||||||
_x = SimpleNamespace(
|
_x = SimpleNamespace(
|
||||||
hooks=hooks,
|
hooks=hooks,
|
||||||
|
run_in_thread=run_in_thread,
|
||||||
)
|
)
|
||||||
|
12
reflex/experimental/misc.py
Normal file
12
reflex/experimental/misc.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
"""Miscellaneous functions for the experimental package."""
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
|
async def run_in_thread(func):
|
||||||
|
"""Run a function in a separate thread.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
func (callable): The function to run.
|
||||||
|
"""
|
||||||
|
await asyncio.get_event_loop().run_in_executor(None, func)
|
Loading…
Reference in New Issue
Block a user