Skip to content
Myr

document session lifetime and possible concurrency issues

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent c8bf420 · Browse files · 1 file+20 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Evgeny Prigorodov <eprigorodov@gmail.com>

Diff stats

1 file+20 added−8 removed

  • other:+20 added−8 removed

1 file+20 added−8 removed

modified:src/flask/sessions.py+20 added-8 removed
129 unmodified lines
130131 app = Flask(__name__)132 app.session_interface = MySessionInterface()133134 Multiple requests with the same session may be sent and handled135 concurrently. When implementing a new session interface, consider136 whether reads or writes to the backing store must be synchronized.137 There is no guarantee on the order in which the session for each138 request is opened or saved, it will occur in the order that requests139 begin and end processing.140141 .. versionadded:: 0.8142 """143144 #: :meth:`make_null_session` will look here for the class that should
153 unmodified lines
298299 def open_session(300 self, app: "Flask", request: "Request"301 ) -> t.Optional[SessionMixin]:295 """This method has to be implemented and must either return ``None``296 in case the loading failed because of a configuration error or an297 instance of a session object which implements a dictionary like298 interface + the methods and attributes on :class:`SessionMixin`.302 """This is called at the beginning of each request, after303 pushing the request context, before matching the URL.304305 This must return an object which implements a dictionary-like306 interface as well as the :class:`SessionMixin` interface.307308 This will return ``None`` to indicate that loading failed in309 some way that is not immediately an error. The request310 context will fall back to using :meth:`make_null_session`311 in this case.312 """313 raise NotImplementedError()314315 def save_session(316 self, app: "Flask", session: SessionMixin, response: "Response"317 ) -> None:305 """This is called for actual sessions returned by :meth:`open_session`306 at the end of the request. This is still called during a request307 context so if you absolutely need access to the request you can do308 that.318 """This is called at the end of each request, after generating319 a response, before removing the request context. It is skipped320 if :meth:`is_null_session` returns ``True``.321 """322 raise NotImplementedError()323324
92 unmodified lines