We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents e79aecf + d9fbfc0 commit fad232bCopy full SHA for fad232b
server/Server.py
@@ -7,6 +7,8 @@
7
from flask import jsonify
8
import shutil
9
from filelock import FileLock
10
+import threading
11
+import time
12
13
TRIMMED_LOGS = False
14
@@ -25,6 +27,16 @@
25
27
SEPARATOR = "/"
26
28
WORKDIR = "userfiles/"
29
30
+CLEANUP_PERIOD=3600
31
+#lightweight daemon to clear abandoned sessions and lockfiles
32
+def gc_sessions():
33
+ while True:
34
+ time.sleep(CLEANUP_PERIOD) #run periodically
35
+ for directory in glob.glob(WORKDIR + "*"):
36
+ if os.path.isdir(directory) and time.time() - os.path.getmtime(directory) > CLEANUP_PERIOD:
37
+ shutil.rmtree(directory, ignore_errors=True)
38
+threading.Thread(target=gc_sessions, daemon=True).start()
39
+
40
@app.route('/')
41
def hello_world():
42
return render_template('home.html')
0 commit comments