Would be very strange but the main difference between pypy and cpython is the garbage collection in cPython is usually immediate for an object withotu reference cycles whereas in Pypy it's not immediate. If this example were in a test suite where the "B" table were created in a transient way such that it goes away once some resource like a connection or similar is garbage collected, the behavior could differ in Pypy vs. cPython.
it would be pretty tough to make the above happen however especially that PostgreSQL creates tables in isolated transactions. so, like all such issues, you need to turn on SQL logging /echoing and watch as the "B" is created, ensure it exists, and then detect if "B" is somehow going away or being dropped ahead of time. On Thu, Aug 13, 2020, at 3:43 PM, Ankit Soni wrote: > We are attempting to move to CPython from PyPy (both version 2.7), but I'm > seeing some baffling errors in the process. > > We are using SQLAlchemy 1.3.11, Flask-SqlAlchemy 2.4.11, psyocpg2cffi, > postgres in our application. > > > There is an "A" model with a post create hook like: > > event.listen(A.__table__, "after_create", create_default_A) > > def create_default_A(): > a = A(....) > db.session.add(a) > db.session.flush() > b = B(...., a_id = a.id) > db.session.add(b) > db.session.commit() > This works fine with PyPy, however, with CPython, the commit fails with an > error from postgres saying the "B" table does not exist. > > As far as I understand there should be no difference. What is going wrong > here? > > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/8a0a9158-7b4f-44f5-9aec-0247b03c50edn%40googlegroups.com > > <https://groups.google.com/d/msgid/sqlalchemy/8a0a9158-7b4f-44f5-9aec-0247b03c50edn%40googlegroups.com?utm_medium=email&utm_source=footer>. -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/3cf08616-bc2d-4cee-a2b8-d2d3d970a168%40www.fastmail.com.
