Aitron Emper commited on
Commit
dc8f793
1 Parent(s): 2f64a94

Update delete_models.py

Browse files
Files changed (1) hide show
  1. delete_models.py +10 -5
delete_models.py CHANGED
@@ -3,10 +3,12 @@ import os
3
  import time
4
  import threading
5
  import shutil
 
6
 
7
  now_dir = os.getcwd()
8
  sys.path.append(now_dir)
9
 
 
10
 
11
  def infinite_loop():
12
  while True:
@@ -19,8 +21,9 @@ def infinite_loop():
19
  shutil.rmtree(element_route)
20
  elif os.path.isfile(element_route):
21
  os.remove(element_route)
22
- except:
23
- pass
 
24
  try:
25
  audios_folder = os.path.join(now_dir, "audios")
26
 
@@ -28,12 +31,14 @@ def infinite_loop():
28
  element_route = os.path.join(audios_folder, element)
29
  if os.path.isfile(element_route):
30
  os.remove(element_route)
 
 
31
 
32
- except:
33
- pass
34
- wait_time = 24 * 60 * 60 #
35
  time.sleep(wait_time)
36
 
37
  def start_infinite_loop():
38
  hilo_bucle = threading.Thread(target=infinite_loop)
 
39
  hilo_bucle.start()
 
3
  import time
4
  import threading
5
  import shutil
6
+ import logging
7
 
8
  now_dir = os.getcwd()
9
  sys.path.append(now_dir)
10
 
11
+ logging.basicConfig(level=logging.DEBUG)
12
 
13
  def infinite_loop():
14
  while True:
 
21
  shutil.rmtree(element_route)
22
  elif os.path.isfile(element_route):
23
  os.remove(element_route)
24
+ except Exception as e:
25
+ logging.error(f"Error in models_folder loop: {e}")
26
+
27
  try:
28
  audios_folder = os.path.join(now_dir, "audios")
29
 
 
31
  element_route = os.path.join(audios_folder, element)
32
  if os.path.isfile(element_route):
33
  os.remove(element_route)
34
+ except Exception as e:
35
+ logging.error(f"Error in audios_folder loop: {e}")
36
 
37
+ wait_time = 24 * 60 * 60
38
+ logging.info(f"Sleeping for {wait_time} seconds")
 
39
  time.sleep(wait_time)
40
 
41
  def start_infinite_loop():
42
  hilo_bucle = threading.Thread(target=infinite_loop)
43
+ hilo_bucle.daemon = True
44
  hilo_bucle.start()