You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2020/09/07 10:12:17 UTC
[incubator-ponymail-foal] branch master updated: copy session so we
won't try to share a database connection among multiple uses
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
The following commit(s) were added to refs/heads/master by this push:
new 5f2d66c copy session so we won't try to share a database connection among multiple uses
5f2d66c is described below
commit 5f2d66cb9d6a6dd533e598781acc92beb36307f5
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Mon Sep 7 12:12:05 2020 +0200
copy session so we won't try to share a database connection among multiple uses
---
server/plugins/session.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/server/plugins/session.py b/server/plugins/session.py
index bd5abff..1b7ca88 100644
--- a/server/plugins/session.py
+++ b/server/plugins/session.py
@@ -26,6 +26,7 @@ import aiohttp.web
import plugins.database
import plugins.server
+import copy
PYPONY_MAX_SESSION_AGE = 86400 * 7 # Max 1 week between visits before voiding a session
@@ -100,7 +101,9 @@ async def get_session(
if (now - x_session.last_accessed) > PYPONY_MAX_SESSION_AGE:
del server.data.sessions[session_id]
else:
- session = x_session
+ # Make a copy so we don't have a race condition with the database pool object
+ # In case the session is used twice within the same loop
+ session = copy.copy(x_session)
if not session:
session = SessionObject(server)
session.database = await server.dbpool.get()