LordXido commited on
Commit
53a70ee
·
verified ·
1 Parent(s): f62e932

Update codexmesh_sync.py

Browse files
Files changed (1) hide show
  1. codexmesh_sync.py +19 -9
codexmesh_sync.py CHANGED
@@ -1,11 +1,21 @@
1
-
2
- import time
3
  import threading
 
 
 
 
 
 
 
 
 
 
4
 
5
- def CodexMeshSync():
6
- def heartbeat():
7
- while True:
8
- print("🔁 CodexMesh Node Alive — Heartbeat Sync")
9
- time.sleep(60)
10
- thread = threading.Thread(target=heartbeat, daemon=True)
11
- thread.start()
 
 
 
 
 
1
  import threading
2
+ import time
3
+ import asyncio
4
+ from codexmesh_stream import emit_event
5
+
6
+ class CodexMeshSync:
7
+ def __init__(self, interval=10):
8
+ self.interval = interval
9
+ self.running = True
10
+ thread = threading.Thread(target=self._heartbeat_loop, daemon=True)
11
+ thread.start()
12
 
13
+ def _heartbeat_loop(self):
14
+ while self.running:
15
+ try:
16
+ asyncio.run(emit_event("heartbeat", {
17
+ "status": "alive"
18
+ }))
19
+ except Exception:
20
+ pass
21
+ time.sleep(self.interval)