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] cannot pickle 'SSLContext' with background callback #2827
Comments
Are you using the SQLAlchemy engine defined globally elsewhere? |
The engine is not a global object but a property of an object created in the callback. Roughly: class DBHandle:
def __init__(self, url, schema):
connect_args = {...}
self.engine = sqlalchemy.create_engine(
url,
echo=True,
pool_pre_ping=True,
connect_args=connect_args,
execution_options={"schema_translate_map": {None: schema}},
)
@dash.callback(
[...]
prevent_initial_call=True,
background=True,
manager=BACKGROUND_CALLBACK_MANAGER,
)
def _callback():
dbh = DBHandle(url, schema) I'll try with Celery if I can't find a solution but it would be nice and make development easier if it could work with a local cache. |
Could you try running your app with:
With that option the stacktrace in the screenshot should have more info to help identify which variable is causing the issue. |
Thanks for the suggestion. After some digging, I realized the |
Yes, we use |
Describe your context
Windows 11, Python 3.9
Occurs with Edge & Chrome.
Describe the bug
I use a background callback in a multi-page app that throws an error when called:
TypeError: cannot pickle 'SSLContext' object
in the browser (without more details, see screenshot below)Here's how the callback is defined:
The callback involves an object that has a SQLAlchemy engine as an attribute. The connection is made through SSL, so I guess this is the object that fails to be pickled. However, I can serialize this object successfully with
dill.dumps
, so I'm not sure...Maybe related to uqfoundation/dill#308, but until the issue is fixed, there might be a workaround?
Expected behavior
I expect the callback to run without error.
Screenshots
The text was updated successfully, but these errors were encountered: