Add 16 fetch limit if no tsdb data found

m4_corrections
Tyler Goodlet 2022-04-24 11:39:34 -04:00
parent c3b43d7ae9
commit 8fd5b95fb9
1 changed files with 14 additions and 2 deletions

View File

@ -37,6 +37,7 @@ from trio.abc import ReceiveChannel
from trio_typing import TaskStatus from trio_typing import TaskStatus
import tractor import tractor
from pydantic import BaseModel from pydantic import BaseModel
import pendulum
import numpy as np import numpy as np
from ..brokers import get_brokermod from ..brokers import get_brokermod
@ -260,10 +261,21 @@ async def start_backfill(
# let caller unblock and deliver latest history frame # let caller unblock and deliver latest history frame
task_status.started(shm) 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 # pull new history frames until we hit latest
# already in the tsdb # already in the tsdb
# while start_dt > last_tsdb_dt: mx_fills = 16
while True: 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) array, start_dt, end_dt = await hist(end_dt=start_dt)
to_push = diff_history( to_push = diff_history(
array, array,