well, the whole function itself is not async (where the session gets created and closed), neither the psycopg2 connection, but inside this chaos, providing the function to run into it's own thread seems to work now ... go figure.

thanks! :)


On 08/06/2015 04:19 PM, Mike Bayer wrote:


On 8/6/15 3:03 PM, Richard Gerd Kuesters wrote:
thanks Mike!

ok, going further then:

1. i'm using postgres (isolation_level="REPEATABLE READ");
2. it's inside a twisted app, into a defer, _but_ the session lifecycle starts and ends in that defer; 3. in that same (python) process, there's a txpostgres connection ongoing (in another twisted defer anywhere).

can some of that cause any "interference" that can cause this behaviour?

inside of a twisted defer and this is not inside a threadpool? absolutely. that's entirely chaotic and anything goes. ironic considering the "simple and safe" promises of explicit async code !








On 08/06/2015 03:29 PM, Mike Bayer wrote:


On 8/6/15 1:50 PM, Richard Gerd Kuesters wrote:
well, i ran today into an issue i never seen before.

considering this simple example:

    session = get_session()
    objs = []

    for ign in xrange(10):
        o = NewObject()
        objs.append(o)

    session.add_all(objs)
    session.commit()

    for obj in objs:
        print obj in session


this will print True only in the first iteration. basically, the other objects are not bound to a session anymore. is there any reason for this, or am i doing something wrong?

cant reproduce:

from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()


class NewObject(Base):
    __tablename__ = 'a'
    id = Column(Integer, primary_key=True)

e = create_engine("sqlite://", echo=True)
Base.metadata.create_all(e)

session = Session(e)

objs = []

for ign in xrange(10):
    o = NewObject()
    objs.append(o)

session.add_all(objs)
session.commit()

for obj in objs:
    print obj in session

output:

<sql stuff...>
2015-08-06 14:28:58,563 INFO sqlalchemy.engine.base.Engine COMMIT
True
True
True
True
True
True
True
True
True
True






best regards,
richard.
--
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 <mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
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 <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
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 <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
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 <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
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 post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

<<attachment: richard.vcf>>

Reply via email to