MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / sess_expire

Method sess_expire

script/task_script_extension.py:242–271  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

240
241 # session过期处理
242 def sess_expire(self):
243 self.sess_expire_sql()
244 try:
245 sess_path = os.path.join(PANEL_PATH, 'data/session')
246 if not os.path.exists(sess_path):
247 return
248 s_time = time.time()
249 f_list = os.listdir(sess_path)
250 f_num = len(f_list)
251 sess_out_path = '{}/data/session_timeout.pl'.format(PANEL_PATH)
252 session_timeout = 86400
253 if os.path.exists(sess_out_path):
254 try:
255 session_timeout = int(public.readFile(sess_out_path))
256 except:
257 pass
258 for fname in f_list:
259 filename = os.path.join(sess_path, fname)
260 fstat = os.stat(filename)
261 f_time = s_time - fstat.st_mtime
262 if f_time > session_timeout:
263 os.remove(filename)
264 continue
265 if fstat.st_size < 256 and len(fname) == 32:
266 if f_time > 60 or f_num > 30:
267 os.remove(filename)
268 continue
269 del f_list
270 except Exception as ex:
271 self.write_log(str(ex))
272
273 def sess_expire_sql(self):
274 try:

Callers 1

check502TaskMethod · 0.95

Calls 10

sess_expire_sqlMethod · 0.95
write_logMethod · 0.95
timeMethod · 0.80
listdirMethod · 0.80
readFileMethod · 0.80
statMethod · 0.80
joinMethod · 0.45
existsMethod · 0.45
formatMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected