Fixed adding duplicate jobs, now gracefully handles

This commit is contained in:
=
2025-09-10 13:59:31 -04:00
parent 14f1a78e5f
commit 13139d7dea
3 changed files with 157 additions and 102 deletions
+13 -7
View File
@@ -65,11 +65,17 @@ def monitorOTP(url, pups):
getActiveOTP(url)
if not os.path.exists("OTP\\old_active_OTP"):
shutil.copy2("OTP\\PARQ\\newest_active_OTP.parquet", "OTP\\PARQ\\old_active_OTP.parquet")
old_active_OTP = pd.read_parquet("OTP\\PARQ\\old_active_OTP.parquet")
current_active_OTP = pd.read_parquet("OTP\\PARQ\\newest_active_OTP.parquet")
old_otp_path = "OTP\\PARQ\\old_active_OTP.parquet"
new_otp_path = "OTP\\PARQ\\newest_active_OTP.parquet"
if os.path.exists(old_otp_path):
old_active_OTP = pd.read_parquet(old_otp_path)
else:
old_active_OTP = pd.DataFrame(columns=['otpid']) # Ensure expected column exists
current_active_OTP = pd.read_parquet(new_otp_path)
newly_added = current_active_OTP[~current_active_OTP['otpid'].isin(old_active_OTP['otpid'])]
still_in_OTP = old_active_OTP[old_active_OTP['otpid'].isin(current_active_OTP['otpid'])]
@@ -79,14 +85,14 @@ def monitorOTP(url, pups):
for _, row in newly_added.iterrows():
clientid = row['clientid']
duration = (row['duration'] * 60)
duration = (int(row['duration']) * 60)
hostname = row['hostname']
purpose = row ['purpose']
pid = row['otpid']
early = math.floor(duration * .9)
run_once_job(f"Add activity hashes for {pid}, for {hostname} for the purpose: {purpose}, early run", "addhash", time.time() + early, args=[url, clientid, pid, pups])
run_once_job(f"Add activity hashes for {pid}, for {hostname} for the purpose: {purpose}, duration complete run", "addhash", time.time() + duration, args=[url, clientid, pid, pups])
run_once_job(f"Add activity hashes for {pid}, for {hostname} for the purpose: {purpose}, early run", "addhash", time.time() + early, [url, clientid, pid, pups], None)
run_once_job(f"Add activity hashes for {pid}, for {hostname} for the purpose: {purpose}, duration complete run", "addhash", time.time() + duration, [url, clientid, pid, pups], None)
print(f"Processing: {pid} with other data: {row}")