dash interval updated

This commit is contained in:
Dobromir Popov
2025-06-24 19:12:12 +03:00
parent 97f7f54c30
commit 165b3be21a
2 changed files with 17 additions and 9 deletions

View File

@ -121,7 +121,7 @@ class COBDashboardServer:
# Initialize COB integration
self.cob_integration = COBIntegration(symbols=self.symbols)
self.cob_integration.add_dashboard_callback(self._on_cob_update)
self.cob_integration.add_dashboard_callback(self._sync_cob_update_wrapper)
# Start COB data streaming as background task
asyncio.create_task(self.cob_integration.start())
@ -319,6 +319,14 @@ class COBDashboardServer:
except Exception as e:
logger.error(f"Error handling WebSocket message: {e}")
def _sync_cob_update_wrapper(self, symbol: str, data: Dict):
"""Sync wrapper for async COB update handler"""
try:
# Create async task to handle the update
asyncio.create_task(self._on_cob_update(symbol, data))
except Exception as e:
logger.error(f"Error in COB update wrapper for {symbol}: {e}")
async def _on_cob_update(self, symbol: str, data: Dict):
"""Handle COB updates from integration"""
try:
@ -504,7 +512,7 @@ class COBDashboardServer:
except Exception:
self.websocket_connections.discard(ws)
await asyncio.sleep(5) # Update every 5 seconds
await asyncio.sleep(1) # Update every 1 second for real-time responsiveness
except Exception as e:
logger.error(f"Error in periodic stats update: {e}")