On Sun, Jun 3, 2018 at 11:42 PM, rvd <[email protected]> wrote:
> Hi Mike,
>
> Thanks for the quick reply. I am using Version 9.6.6 (RDS). Not using any
> proxy. Because this was a rather blocking issue, I have been utilizing a
> terrible workaround (namely creating an engine every single request, and
> using that session) with some success - obviously not ideal though. I have
> tried reducing the pool_recycle parameter to 60 seconds; I came across the
> ping thing as well during my research - will give that a try too and let you
> know. Thank you a ton again for the suggestions, they are very much
> appreciated.


you never need to create engine per request, pooling is turned off
entirely using NullPool:

http://docs.sqlalchemy.org/en/latest/core/pooling.html#switching-pool-implementations


>
> rvd
>
> On Sunday, June 3, 2018 at 7:17:55 PM UTC-7, rvd wrote:
>>
>> Hi all,
>>
>> I am writing a Flask API that needs to communicate with many datastores,
>> Postgres on AWS RDS being one of them. I want to avoid Flask-SQLAlchemy
>> (trying to reduce package dependence); I think the standard SQLAlchemy
>> library should suffice. I have described the issue thoroughly here (code is
>> here as well).  But here is the synopsis. When I use a Session object in my
>> app, for the first few requests, it works great. Then, if I wait for a while
>> and fire off another request, I get a Psycopg2 error about the server
>> closing off the connection unexpectedly. This is rather crippling. I have
>> spent a lot of time going through SO, asked in the SQLAlchemy IRC channel,
>> and tried many tutorials, and this seems to be a standard valid pattern, so
>> I am not sure what is going wrong. Should I not be removing the session?
>> Should I be using the @app.teardown_appcontext decorator (it seems that if I
>> just remove the sessions myself as I am doing now, I shouldn't have to)?
>> Should I be using a connection pool instead (it seems that QueuePool is
>> enabled under the hood by default anyway)? If it helps, I am using the
>> latest version of all packages, Python 3.6.5, and Postman to send the
>> requests to the server, which is running at localhost:5000. Any advice would
>> be much appreciated - thanks in advance!
>>
>> Best,
>> rvd
>
> --
> 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 post to this group, send email to [email protected].
> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to