I’m trying to get background callback to work with diskcache. The example works find (sleep for 1 second, etc), but when I try to use my real function (which makes an api request using the
requests package), i get this:
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
Is this typical? I’m on a new M1 mac, i thought maybe that could be the problem? Or my python version (which i’ve tried everywhere from 3.6 to 3.11).
I was able to use requests:
from dash import DiskcacheManager, CeleryManager, Input, Output, html
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 = CeleryManager(celery_app)
# Diskcache for non-production apps when developing locally
cache = diskcache.Cache("./cache")
background_callback_manager = DiskcacheManager(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!"),
r = requests.get('https://google.com')
if __name__ == "__main__":
I did finally figure this out. It turns out, I was importing a package that was importing something from turtle for some reason, and not even using it. Once I removed that import, everything worked like a charm.