superlocalmemory 3.4.33 → 3.4.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -422,6 +422,27 @@ async def lifespan(application: FastAPI):
422
422
  logger.warning("Embedding warmup failed: %s", exc)
423
423
  threading.Thread(target=_warmup_embedder, daemon=True, name="embed-warmup").start()
424
424
 
425
+ # v3.4.26: Start QueueConsumer — drains recall_queue.db via pool.recall().
426
+ # Must start AFTER WorkerPool.warmup() so the worker is ready.
427
+ try:
428
+ from pathlib import Path as _QP
429
+ from superlocalmemory.core.queue_consumer import QueueConsumer
430
+ from superlocalmemory.core.recall_queue import RecallQueue
431
+ _queue_db = _QP.home() / ".superlocalmemory" / "recall_queue.db"
432
+ _recall_queue = RecallQueue(_queue_db)
433
+ _queue_consumer = QueueConsumer(
434
+ queue=_recall_queue,
435
+ pool=WorkerPool.shared(),
436
+ )
437
+ _queue_consumer.start()
438
+ application.state.queue_consumer = _queue_consumer
439
+ application.state.recall_queue = _recall_queue
440
+ logger.info("QueueConsumer started (recall_queue.db)")
441
+ except Exception as _qc_exc:
442
+ logger.warning("QueueConsumer start failed (non-fatal): %s", _qc_exc)
443
+ application.state.queue_consumer = None
444
+ application.state.recall_queue = None
445
+
425
446
  except Exception as exc:
426
447
  logger.warning("Engine init failed: %s", exc)
427
448
  application.state.engine = None
@@ -571,6 +592,20 @@ async def lifespan(application: FastAPI):
571
592
  except Exception as exc: # pragma: no cover — defensive
572
593
  logger.warning("bandit_tasks cancel failed: %s", exc)
573
594
 
595
+ # v3.4.26: Stop QueueConsumer (recall_queue.db drainer).
596
+ _qc = getattr(application.state, "queue_consumer", None)
597
+ if _qc is not None:
598
+ try:
599
+ _qc.stop()
600
+ except Exception as exc: # pragma: no cover — defensive
601
+ logger.warning("queue_consumer stop failed: %s", exc)
602
+ _rq = getattr(application.state, "recall_queue", None)
603
+ if _rq is not None:
604
+ try:
605
+ _rq.close()
606
+ except Exception as exc: # pragma: no cover — defensive
607
+ logger.warning("recall_queue close failed: %s", exc)
608
+
574
609
  # Stop HealthMonitor (health_monitor.py owns a daemon thread).
575
610
  _health = getattr(application.state, "health_monitor", None)
576
611
  if _health is not None: