Skip to content

Commit

Permalink
Update task_runner.py
Browse files Browse the repository at this point in the history
try flushing logs to see if docker can catch them sooner
  • Loading branch information
LucifersCircle committed Dec 7, 2024
1 parent e549f8f commit d71e217
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions task_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ def fetch_keys():
# Decrypt each key before returning
keys = [cipher.decrypt(row[0]).decode() for row in cursor.fetchall()]
conn.close()
print(f"Fetched and decrypted {len(keys)} keys from the database.")
print(f"Fetched and decrypted {len(keys)} keys from the database.", flush=True)
return keys
except Exception as e:
print(f"Error fetching keys: {e}")
print(f"Error fetching keys: {e}", flush=True)
return []

def send_request(token):
Expand All @@ -39,16 +39,17 @@ def send_request(token):
try:
response = requests.get(url)
masked_token = mask_token(token)
print(f"Request to {masked_token} returned status code {response.status_code}.")
print(f"Request to {masked_token} returned status code {response.status_code}.", flush=True)
except requests.RequestException as e:
print(f"Failed to send request for token {mask_token(token)}: {e}")
print(f"Failed to send request for token {mask_token(token)}: {e}", flush=True)

if __name__ == "__main__":
print("Starting task_runner...", flush=True)
while True:
keys = fetch_keys()
if not keys:
print("No keys found in the database.")
print("No keys found in the database.", flush=True)
for key in keys:
send_request(key)
print(f"Sleeping for {interval} seconds.")
print(f"Sleeping for {interval} seconds.", flush=True)
time.sleep(interval)

0 comments on commit d71e217

Please sign in to comment.