Background callback error with requests

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().

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).

Hello @aboyher,

I was able to use requests:


import time
import os

import dash
from dash import DiskcacheManager, CeleryManager, Input, Output, html
import requests

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
    import diskcache
    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!"),

    output=Output("paragraph_id", "children"),
    inputs=Input("button_id", "n_clicks"),
def update_clicks(n_clicks):
    r = requests.get('')
    return [r.content]

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.