Don't open stream before starting the fsp context..

fsp_hotfixes
Tyler Goodlet 2021-11-05 10:04:10 -04:00
parent ea9b66d1c3
commit 2b97f98151
1 changed files with 18 additions and 18 deletions

View File

@ -79,7 +79,7 @@ async def filter_quotes_by_sym(
async def fsp_compute(
stream: tractor.MsgStream,
ctx: tractor.Context,
symbol: str,
feed: Feed,
quote_stream: trio.abc.ReceiveChannel,
@ -147,6 +147,7 @@ async def fsp_compute(
# setup a respawn handle
with trio.CancelScope() as cs:
tracker = TaskTracker(trio.Event(), cs)
await ctx.started(index)
task_status.started((tracker, index))
profiler(f'{func_name} yield last index')
@ -155,6 +156,7 @@ async def fsp_compute(
try:
# rt stream
async with ctx.open_stream() as stream:
async for processed in out_stream:
log.debug(f"{func_name}: {processed}")
@ -229,14 +231,13 @@ async def cascade(
# last_len = new_len = len(src.array)
async with (
ctx.open_stream() as stream,
trio.open_nursery() as n,
):
fsp_target = partial(
fsp_compute,
stream=stream,
ctx=ctx,
symbol=symbol,
feed=feed,
quote_stream=quote_stream,
@ -255,7 +256,6 @@ async def cascade(
last = dst.array[-1:]
zeroed = np.zeros(last.shape, dtype=last.dtype)
await ctx.started(index)
profiler(f'{func_name}: fsp up')
async def resync(tracker: TaskTracker) -> tuple[TaskTracker, int]: