import asyncio from app.db.session import SessionLocal from app.services.auto_sync import run_due_jobs async def loop() -> None: print("NexaFabric worker started. Auto-sync scheduler is active.", flush=True) while True: try: with SessionLocal() as db: results = await run_due_jobs(db) for result in results: print(f"auto-sync: {result}", flush=True) except Exception as exc: print(f"auto-sync failed: {exc}", flush=True) await asyncio.sleep(30) def main() -> None: asyncio.run(loop()) if __name__ == "__main__": main()