Skip to content

Commit b9d2053

Browse files
committed
Delete expired session files when there is no traffic
Most HTTP requests create a file in the sessions directory. Open browsers call "/misc/cleanup" every five minutes, but session files can accumulate after browsers are closed. Wake periodically to delete expired sessions according to the CHECK_SESSION_FILES_INTERVAL setting. Fixes: #1999 Fixes: #8355
1 parent 660a9b0 commit b9d2053

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

web/pgadmin/misc/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,20 @@ def register(self, app, options):
156156
from .workspaces import blueprint as module
157157
self.submodules.append(module)
158158

159+
def autovacuum_sessions():
160+
import threading
161+
162+
with app.app_context():
163+
cleanup_session_files()
164+
165+
# repeat every five minutes until exit
166+
# https://github.com/python/cpython/issues/98230
167+
t = threading.Timer(5 * 60, autovacuum_sessions)
168+
t.daemon = True
169+
t.start()
170+
171+
app.register_before_app_start(autovacuum_sessions)
172+
159173
super().register(app, options)
160174

161175

0 commit comments

Comments
 (0)