You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Explicit thread pool executor for sync event handlers #6225
enhancementAnything you want improvedroadmaphttps://github.com/reflex-dev/reflex/issues/2727
Move sync EventHandler execution to an explicit thread pool executor. The @rx.event decorator should accept an optional executor kwarg that determines which executor (or the default) is used to run the function.
There should be a new default_executor field in rx.Config that accepts either a ThreadPoolExecutor or a string pointing to an importable ThreadPoolExecutor or function that returns a ThreadPoolExecutor.
Passing None for the executor will just run the function on the event processing thread like before (no immediate behavior change, must opt in)
Details
Sync functions get wrapped in loop.run_in_executor() transparently, so callers always await regardless of whether the underlying function is sync or async. This aligns with the EventHandler redesign where every handler is simply awaitable.
Custom executors allow tuning:
A CPU-bound handler can use a ProcessPoolExecutor
A DB-heavy handler can use a dedicated thread pool with limited concurrency
Default executor handles the common case
This largely eliminates the most common source of event loop blocking — sync handlers that do I/O or CPU work on the main thread.
Related
Works in tandem with event loop blocking detection (Linear ENG-6436) — if a sync handler accidentally bypasses the executor, blocking detection catches it.
enhancementAnything you want improvedroadmaphttps://github.com/reflex-dev/reflex/issues/2727
Activity
linear commentedon Mar 25, 2026
ENG-9164