-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dash Plotly long callback error #493
Comments
The long callback manager requires the source code of the python script/module where If you are using If the code that uses To illustrate on an example, suppose we have an entry point `program.py˙ (code taken from here): program.py
# program.py
import time
import dash
from dash import html
from dash.long_callback import DiskcacheLongCallbackManager
from dash.dependencies import Input, Output
## Diskcache
import diskcache
cache = diskcache.Cache("./cache")
long_callback_manager = DiskcacheLongCallbackManager(cache)
app = dash.Dash(__name__)
app.layout = html.Div(
[
html.Div([html.P(id="paragraph_id", children=["Button not clicked"])]),
html.Button(id="button_id", children="Run Job!"),
]
)
@app.long_callback(
output=Output("paragraph_id", "children"),
inputs=Input("button_id", "n_clicks"),
manager=long_callback_manager,
)
def callback(n_clicks):
time.sleep(2.0)
return [f"Clicked {n_clicks} times"]
if __name__ == "__main__":
app.run_server(debug=True) Building with
Collecting the entry-point script as a data file,
which looks like incompatibility between PyInstaller's FrozenImporter and attributes that This can be worked around by disabling the debug mode on This gets the application running and allows us to connect to its web server, but the button doesn't work. That's because behind the scenes, if __name__ == "__main__":
import multiprocessing
multiprocessing.freeze_support()
app.run_server(debug=False) After rebuilding again, the example seems to work as expected If you need the debug mode ( program.spec
Then build by running PyInstaller against the spec file instead of the entry-point:
(NOTE: the above example is for
That's probably due to how you set up your cache directories. If you did it like in the above example, i.e., ## Diskcache
import diskcache
cache = diskcache.Cache("./cache")
long_callback_manager = DiskcacheLongCallbackManager(cache) then |
<>
I get this error when I try to use a dash plotly app with long callback functionality:
Traceback (most recent call last):
File "cmt_appnge_copy.py", line 605, in
File "dash_callback.py", line 310, in wrap_func
File "dash\long_callback\managers_init_.py", line 83, in register_func
File "dash\long_callback\managers_init_.py", line 103, in hash_function
File "inspect.py", line 1024, in getsource
File "inspect.py", line 1006, in getsourcelines
File "inspect.py", line 835, in findsource
OSError: could not get source code
Also, after initiating the start of the executable there are two cache folders created:
I do not know what the error could be.
The text was updated successfully, but these errors were encountered: