main
Last change
on this file was
42bd667,
checked in by David Fuertes <dfuertes@…>, 4 years ago
|
Historial Limpio
|
-
Property mode set to
100755
|
File size:
906 bytes
|
Line | |
---|
1 | |
---|
2 | import os, time, stat, logging |
---|
3 | from gluon._compat import pickle |
---|
4 | |
---|
5 | EXPIRATION_MINUTES = 60 |
---|
6 | |
---|
7 | path = os.path.join(request.folder, 'sessions') |
---|
8 | if not os.path.exists(path): |
---|
9 | os.mkdir(path) |
---|
10 | now = time.time() |
---|
11 | for path, dirs, files in os.walk(path, topdown=False): |
---|
12 | for x in files: |
---|
13 | fullpath = os.path.join(path, x) |
---|
14 | try: |
---|
15 | filetime = os.stat(fullpath)[stat.ST_MTIME] # get it before our io |
---|
16 | try: |
---|
17 | session_data = pickle.load(open(fullpath, 'rb+')) |
---|
18 | expiration = session_data['auth']['expiration'] |
---|
19 | except: |
---|
20 | expiration = EXPIRATION_MINUTES * 60 |
---|
21 | if (now - filetime) > expiration: |
---|
22 | os.unlink(fullpath) |
---|
23 | except: |
---|
24 | logging.exception('failure to check %s' % fullpath) |
---|
25 | for d in dirs: |
---|
26 | dd = os.path.join(path, d) |
---|
27 | if not os.listdir(dd): |
---|
28 | os.rmdir(dd) |
---|
Note: See
TracBrowser
for help on using the repository browser.