Spaces:
Sleeping
Sleeping
Update codexmesh_sync.py
Browse files- codexmesh_sync.py +19 -9
codexmesh_sync.py
CHANGED
|
@@ -1,11 +1,21 @@
|
|
| 1 |
-
|
| 2 |
-
import time
|
| 3 |
import threading
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
def
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|