pallets-eco / flask-session

Server side session extension for Flask
https://flask-session.readthedocs.io
BSD 3-Clause "New" or "Revised" License
501 stars 239 forks source link

FileSession not thread-safe #20

Closed viweei closed 9 years ago

viweei commented 9 years ago

FileSession not thread-safe if I use threaded parameter into creating Flask , look as:

app.run (threaded = True)

There are a large number in parallel,

data = self.cache.get (self.key_prefix + sid)

Will return None, but in the file session.py at line 320,

return self.session_class (sid = sid, permanent = self.permanent)

Ah, God, I always wondered why the session will be reset, Now I konw.

viweei commented 9 years ago

FileSystemCache write cache file has not been completed, while reading the cache file cause IOError:. [Errno 13] Permission denied. FileSystemCache write cache file has not been completed, while reading the cache file cause IOError:. [Errno 13] Permission denied.

bottle use threading.local, but Flask use LocalProxy, so it would appear this error Flask run in multiple threads.

Flask 使用 threaded=True 参数运行时会出现这个错误,单线程则不会, 主要是我需要开启threaded,来对付IE的假死情况.