plotly / dash

Data Apps & Dashboards for Python. No JavaScript Required.

Home Page:https://plotly.com/dash

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Allow background callbacks to run in the same process as the main app

franekp opened this issue · comments

Is your feature request related to a problem? Please describe.
Problem: display a "loading..." indicator (or better, a progress bar) while some long in-process computation is running.

There are 3 main reasons why in-process background callbacks are desirable:

  1. Current version of background callbacks requires changes to the deployment environment, they don't work out of the box after pip install dash.
  2. Updating an in-process cache. Having to set up Redis or a database or use files for caching graphs in a simple single-process app is an overkill.
  3. Especially, when results inserted to the in-process cache are non-serializable, such as memory-mapped numpy arrays or pytorch tensors or models which might be on CUDA. Or simply any data structure that doesn't implement serialization.

Describe the solution you'd like
An callback manager (say InProcessManager) that is available after pip instal dash and runs background callbacks in a thread in the same process.

Describe alternatives you've considered
Currently I am using regular callbacks, but have run into #2486 when trying to show loading indicator for the callback. Also, progress bar is not available for regular callbacks, and background callbacks seem to be more natural for this kind of use-case.