On 4/4/15 11:42 AM, Henrique Fleury wrote:
> When the database restarts my services are flooding the database
> connection. I wonder if in SQLAlchemy has a parameter that step
> create_engine () it does a delay between an attempt and another
> connection. I need him to try to connect if you can not it wait X time
> to make a new attempt.
I recently had to do this for some benchmarking. There is no built-in
facility for this as the event system doesn't provide this hook as of
yet (maybe it should); however you can decorate the "creator" after the
fact to produce this effect:
import time
engine = create_engine("...")
_creator = engine.pool._creator
def creator():
time.sleep(.5)
return _creator()
engine.pool._creator = creator
> --
> 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]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.