Giter VIP home page Giter VIP logo

Comments (5)

T4rk1n avatar T4rk1n commented on May 27, 2024

Are you using the SQLAlchemy engine defined globally elsewhere?
The multiprocess will try to transfer it when used but that is not valid pickle/multiprocess object. May need to establish the engine inside the callback for that to work or switch to celery.

from dash.

fxstempfelals avatar fxstempfelals commented on May 27, 2024

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.

from dash.

T4rk1n avatar T4rk1n commented on May 27, 2024

Could you try running your app with:

app.run(debug=True, dev_tools_prune_errors=False)

With that option the stacktrace in the screenshot should have more info to help identify which variable is causing the issue.

from dash.

fxstempfelals avatar fxstempfelals commented on May 27, 2024

Thanks for the suggestion. After some digging, I realized the SSLContext instance is a nested property of botocore.client.S3. This S3 client is not used in the background callback that is the source of the error, but elsewhere in the app. I guess dash serializes the whole execution environment?

from dash.

T4rk1n avatar T4rk1n commented on May 27, 2024

I guess dash serializes the whole execution environment?

Yes, we use multiprocess to spawn the background process and that will try to transfer all the global variables.

from dash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.