[Flask] Jeff Levesque: integrating redis with flask session

ub at artfacts.net ub at artfacts.net
Sat Jan 14 19:35:49 EST 2017


hey jeffrey,

if the situation the way you describe it on that github ticket is still
accurate, then i think the problem is that when you initialize the
session_interface, you are not passing your -- already connected --
redis instance and so RedisSessionInterface.__init__() attches it's own
default one and the defaults might not be right when you're running in a
virtualized environment or networked containers.

so instead of:
app.session_interface = RedisSessionInterface()

do:
app.session_interface = RedisSessionInterface(redis=yourRedis)

where "yourRedis" is the one you know is working for your models "in
other contexts" already.

and you should be fine.

cheers,
ub


On 14.01.2017 16:27, Jeffrey Levesque via Flask wrote:
> It's hard to summarize so much background.  My application has an
> automated build via vagrant for local development.  This vagrant
> environment works as intended on the chrome browser:
> 
> - https://github.com/jeff1evesque/machine-learning/pull/2867#issuecomment-272431783
> 
> The docker environment (currently) is for automated unit tests, handled
> by Travis CI.  But, the build is failing with redis, when integrated
> with the flask session:
> 
> - https://travis-ci.org/jeff1evesque/machine-learning/builds/191619024#L3803
> 
> I spoke to @notdaniel in #pocoo, and he's been really helpful.  He
> helped me with the working vagrant environment.  But, last night he told
> me to try to explicitly define redis strict session, similar to the way
> my application uses it, in other places.
> 
> My application uses redis in other contexts, like generating model, then
> serializing it into redis, so it can be used for future predictions,
> when queried from redis, the. unserialized.  I have unit tests that have
> been integrated into Travis CI, which tests this.  This feature has been
> in place for some time, so I know redis works within my application for
> other needs.
> 
> 
> Thank you,
> 
> Jeff Levesque
> https://github.com/jeff1evesque
> 
> On Jan 14, 2017, at 9:33 AM, Anthony Ford <ford.anthonyj at gmail.com
> <mailto:ford.anthonyj at gmail.com>> wrote:
> 
>> Have you checked the offical Flask plugin, Flask-Session?
>>
>> It has support for Redis, among other backends. Can be found
>> here: https://pythonhosted.org/Flask-Session/
>>
>> That being said, have you tested the redis server outside your
>> application? Are you sure you can connect to it?
>>
>> Anthony Ford,
>> KF5IBN,
>> ford.anthonyj at gmail.com <mailto:ford.anthonyj at gmail.com>
>>
>> On Fri, Jan 13, 2017 at 11:55 PM, Jeffrey Levesque via Flask
>> <flask at python.org <mailto:flask at python.org>> wrote:
>>
>>     Hi All,
>>
>>     I'm trying to integrate redis with flask's session. My motivation
>>     are redis being more secure than the standard cookie
>>     implementation, and slightly better overall performance.
>>
>>     I posted an issue on flasks official github repository, regarding
>>     the exact details:
>>
>>     - https://github.com/pallets/flask/issues/2150
>>     <https://github.com/pallets/flask/issues/2150>
>>
>>     However, the issue was closed, and I was recommended this email
>>     list.  If someone has implemented redis with flask's session, or
>>     have ideas, would you mind assisting?
>>
>>
>>     Thank you,
>>
>>     Jeff Levesque
>>     https://github.com/jeff1evesque <https://github.com/jeff1evesque>
>>     _______________________________________________
>>     Flask mailing list
>>     Flask at python.org <mailto:Flask at python.org>
>>     https://mail.python.org/mailman/listinfo/flask
>>     <https://mail.python.org/mailman/listinfo/flask>
>>
>>
> 
> 
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask
> 



More information about the Flask mailing list