On Fri, Sep 1, 2017 at 12:35 PM, Антонио Антуан <a.ch....@gmail.com> wrote:
> Yes, I tried it and it is worked fine.
> Another thing that I tried to understand: "Are connections, which used by
> `session`, `session.bind`, compiled_query and engine, the same?".
> `pg_stat_activity` shows me, that I am right,
> Can you confirm this statement?

*if* you are using StaticPool and AssertionPool, and you are *not*
using multiple threads against it as in particular AssertionPool is
not really threadsafe (StaticPool is mostly threadsafe though I can
see it might race on the first connect), and also you haven't called
engine.dispose(), then there should be just the one connection hanging
around, yes.    DBAPI connections themselves are not generally
threadsafe so these pools assume single-threaded use.



In such case a warning about deadlocks with
> "reset_on_return=None" not so horrible with StaticPool or AssertionPool.
> Here is code snippet:
> https://gist.github.com/aCLr/61896fc652a0a61a21dbe3531ed695a8

I'm not sure what you're ultimately trying to accomplish but I would
definitely not recommend patterns like StaticPool,
reset_on_return=None for anything significant.   You will leave the
connection hanging open in a transaction while the application is not
doing anything.   I don't see why any of the patterns you are
illustrating should ever be necessary.


>>
>> And when I specify
>> > that parameter with `None` value, failed only first asserion ('failed on
>> > compiled query execution') because, as I think, another connection is
>> > used.
>> > My question is the same: isn't it wrong? And if it is, how can I avoid
>> > AsserionError on compiled query execution? Should I use private
>> > `_connection_for_bind` method of Session class or there are any other
>> > options?
>> >
>> >
>> >
>> > --
>> > 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+...@googlegroups.com.
>> > To post to this group, send email to sqlal...@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/sqlalchemy.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> 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 post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

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

Reply via email to