Fix server hang: stop CTP reconnect storm and throttle live account polling.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -45,6 +45,12 @@ class PositionStreamHub:
|
||||
with self._lock:
|
||||
return dict(self._snapshot) if self._snapshot else None
|
||||
|
||||
def snapshot_age_sec(self) -> float:
|
||||
with self._lock:
|
||||
if not self._snapshot_ts:
|
||||
return 9999.0
|
||||
return max(0.0, time.time() - self._snapshot_ts)
|
||||
|
||||
def set_snapshot(self, data: dict) -> None:
|
||||
with self._lock:
|
||||
self._snapshot = dict(data)
|
||||
|
||||
Reference in New Issue
Block a user