From 1fd35136890d271f58a775906f00f73b64c73372 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 24 Apr 2022 11:39:34 -0400 Subject: [PATCH] Add 16 fetch limit if no tsdb data found --- piker/data/feed.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/piker/data/feed.py b/piker/data/feed.py index ce16f76d..9bca88d8 100644 --- a/piker/data/feed.py +++ b/piker/data/feed.py @@ -37,6 +37,7 @@ from trio.abc import ReceiveChannel from trio_typing import TaskStatus import tractor from pydantic import BaseModel +import pendulum import numpy as np from ..brokers import get_brokermod @@ -260,10 +261,21 @@ async def start_backfill( # let caller unblock and deliver latest history frame task_status.started(shm) + if last_tsdb_dt is None: + # maybe a better default (they don't seem to define epoch?!) + last_tsdb_dt = pendulum.yesterday() + + # pull new history frames until we hit latest # already in the tsdb - # while start_dt > last_tsdb_dt: - while True: + mx_fills = 16 + count = 0 + while ( + start_dt > last_tsdb_dt + and count > mx_fills + ): + # while True: + count += 1 array, start_dt, end_dt = await hist(end_dt=start_dt) to_push = diff_history( array,