The library is now more robust but the test script needs two Ctrl+C's to stop.

This commit is contained in:
Kalzu Rekku
2025-03-16 19:49:00 +02:00
parent dc5d652503
commit 822ea3a453
2 changed files with 128 additions and 56 deletions

View File

@@ -11,7 +11,10 @@ import logging
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s - %(levelname)s - %(message)s",
handlers=[logging.StreamHandler()],
handlers=[
logging.StreamHandler(),
logging.FileHandler("test-slidingsql.log", mode="a") # "a" appends to the file
],
)
# Configuration
@@ -76,7 +79,8 @@ def reader_thread():
query_id = db.execute_read("SELECT e.event_type, u.username, e.event_timestamp FROM events e JOIN users u ON e.user_id = u.id ORDER BY e.event_timestamp DESC LIMIT 5", ())
result = db.get_read_result(query_id)
if result.success:
logging.info(f"Recent events: {result.data}")
log_message = f"Recent events: {result.data}"
logging.info(log_message[:100] + "..." if len(log_message) > 100 else log_message)
time.sleep(random.uniform(0.5, 1.5)) # Randomized sleep for more natural load
# Start multiple writer and reader threads