I haven't used the multiprocessing library, but if it uses pickle to transfer SQLAlchemy objects, it's going to be difficult to make it work. Objects loaded via the SQLAlchemy ORM hold a references to the Session that was used to load them, which in turn holds a reference to a database connection. Pickling the instance therefore tries to pickle the Session as well, which almost certainly isn't what you want.
Rather than passing ORM instances to worker processes, it would probably be better to either: a) Pass a unique identifier for the instance, and have the worker process reload the instance from the database itself, or b) Send simpler (non-SQLAlchemy) objects to the worker, Hope that helps, Simon On Wed, Mar 16, 2022 at 2:34 AM Haris Damara <haris.damara....@gmail.com> wrote: > > Hi, > > Please help. > > Find issue with error message "None! Can't pickle <class > 'sqlalchemy.orm.session.Session'>: it's not the same object as > sqlalchemy.orm.session.Session" > while run the sqlalchemy orm query and/or execute syntax in Process > (multiprocessing) > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/f98608ed-1eb6-49d3-90c2-642973c990f0n%40googlegroups.com. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/CAFHwexcAEJNvyVve_3SBMZi9WL2H_3v18qKLALz3QEC8nMaRZA%40mail.gmail.com.