Files changed (1) hide show
  1. state.py +7 -6
state.py CHANGED
@@ -13,12 +13,14 @@ class AppState:
13
 
14
  self.total_words = 0
15
  self.processed = 0
16
- self.counts = {"taken": 0, "unavailable": 0, "sold": 0, "auction": 0, "available": 0, "forsale": 0}
17
 
18
- self.queue = None # Will be initialized in the event loop
 
 
 
 
19
  self.proxies = []
20
 
21
- # Ensure output directory exists
22
  if not os.path.exists("results"):
23
  os.makedirs("results")
24
 
@@ -31,6 +33,7 @@ class AppState:
31
  for w in words:
32
  await self.queue.put(w)
33
  self.total_words = self.queue.qsize() + self.processed
 
34
 
35
  async def save_result(self, word, status):
36
  self.processed += 1
@@ -39,13 +42,11 @@ class AppState:
39
  if clean_status in self.counts:
40
  self.counts[clean_status] += 1
41
 
42
- # Append immediately to disk so we never lose data on crash
43
  filename = f"results/{clean_status}.txt"
44
  try:
45
  async with aiofiles.open(filename, "a", encoding="utf-8") as f:
46
  await f.write(f"{word}\n")
47
  except Exception as e:
48
- log.error(f"Failed to write {word} to {filename}: {e}")
49
 
50
- # Global singleton instance
51
  state = AppState()
 
13
 
14
  self.total_words = 0
15
  self.processed = 0
 
16
 
17
+ # Explicit counting metrics mapping registers
18
+ self.counts = {"taken": 0, "unavailable": 0, "sold": 0, "auction": 0, "available": 0, "forsale": 0, "error": 0}
19
+ self.fail_counts = {}
20
+
21
+ self.queue = None
22
  self.proxies = []
23
 
 
24
  if not os.path.exists("results"):
25
  os.makedirs("results")
26
 
 
33
  for w in words:
34
  await self.queue.put(w)
35
  self.total_words = self.queue.qsize() + self.processed
36
+ log.info(f"📊 Memory Queue Rebuilt. Active total words count register: {self.total_words}")
37
 
38
  async def save_result(self, word, status):
39
  self.processed += 1
 
42
  if clean_status in self.counts:
43
  self.counts[clean_status] += 1
44
 
 
45
  filename = f"results/{clean_status}.txt"
46
  try:
47
  async with aiofiles.open(filename, "a", encoding="utf-8") as f:
48
  await f.write(f"{word}\n")
49
  except Exception as e:
50
+ log.error(f"Failed to append result tracking entry for {word} to {filename}: {e}")
51
 
 
52
  state = AppState()