-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[BUG] background callback with running
argument causes type error
#2685
Comments
Thanks for reporting this bug, @seb-schulz . Running your code, I get the same error message in the console. But I couldn't get the example to work as expected when the |
Hey @Coding-with-Adam, here is a working example: import os
import dash
from dash import html, dcc
import time
if 'REDIS_URL' in os.environ:
# Use Redis & Celery if REDIS_URL set as an env variable
from celery import Celery
celery_app = Celery(__name__,
broker=os.environ['REDIS_URL'],
backend=os.environ['REDIS_URL'])
background_callback_manager = dash.CeleryManager(celery_app)
else:
# Diskcache for non-production apps when developing locally
import diskcache
cache = diskcache.Cache("./cache")
background_callback_manager = dash.DiskcacheManager(cache)
app = dash.Dash(
__name__,
background_callback_manager=background_callback_manager,
)
class ids:
button = dict(a="button_id")
paragraph = dict(a="paragraph_id")
app.layout = html.Div([
html.P(id=ids.paragraph, children=["Button not clicked"]),
html.Button(id=ids.button, children="Run Job!"),
html.Button(
# id=dict(a='broken_button'),
id='not_broken_button',
children="This button should be disabled while callback is running",
),
])
@dash.callback(
dash.Output(ids.paragraph, "children"),
dash.Input(ids.button, "n_clicks"),
# running=[[dash.Input(dict(a='broken_button'), "disabled"), True, False]],
running=[[dash.Input('not_broken_button', "disabled"), True, False]],
background=True,
prevent_initial_call=True,
)
def update_clicks(*args):
print('started', args)
time.sleep(1)
print('ended', args)
return [
f"Clicked with following args: {args!r}\ndash version: {dash.__version__}"
]
if __name__ == "__main__":
app.run(debug=True) The difference is just using |
Thanks for sharing, @seb-schulz .
I was able to remove this error by converting the id of the first button to a string as well, instead of the dict you used. I'm assuming the reason for these errors is related. |
Hey @Coding-with-Adam, thank you for sharing your findings. It looks like your finding is caused by a chrome extension. Does my second example work when you disable some of those extensions? In Chrome 118 + 119 and Firefox 115, my first example is broken and my second example is working. |
hi @seb-schulz |
Hey @Coding-with-Adam! Yes, I am using pattern matching for example to structure code with All-in-One Components. |
In that case it could be related to this issue: #2681 |
Duplicate of #2111 |
Describe your context
if frontend related, tell us your Browser, Version and OS
Describe the bug
Here is an example to demonstrate my example:
Expected behavior
Console of the developer tools shows the following error:
When the
id
is type of string instead of a dictionary, this example works as expected.The text was updated successfully, but these errors were encountered: