-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground_tasks.py
46 lines (34 loc) · 1.3 KB
/
background_tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import time
import pickle
import threading
from Main import count_db_rows, random_password, KEYSPACE, TABLE
def get_db_status_interval(interval=60):
while True:
try:
results = count_db_rows(keyspace=KEYSPACE, table=TABLE)
with open("/data/Passkull/Web_Data/DB_status", 'wb') as db_status:
pickle.dump(results, db_status)
time.sleep(interval)
except:
continue
def password_of_the_hour(interval=60):
while True:
try:
results = random_password(keyspace=KEYSPACE, table=TABLE)
with open("/data/Passkull/Web_Data/Password_hour", 'wb') as password_file:
pickle.dump(results, password_file)
print('Password File Created!!!!!!')
time.sleep(interval)
except Exception as e:
print(e)
continue
def password_of_the_hour_run_thread():
t = threading.Thread(target=password_of_the_hour, args=tuple())
t.start()
print("Create password of the hour file")
def get_db_status_interval_run_thread():
t = threading.Thread(target=get_db_status_interval, args=tuple())
t.start()
print("Create DB Status file")
password_of_the_hour_run_thread()
get_db_status_interval_run_thread()