Skip to content

Commit

Permalink
Expose allow_overruns to Portal.open_context()
Browse files Browse the repository at this point in the history
Turns out you can get a case where you might be opening multiple
ctx-streams concurrently and during the context opening phase you block
for all contexts to open, but then when you eventually start opening
streams some slow to start context has caused the others become in an
overrun state.. so we need to let the caller control whether that's an
error ;)

This also needs a test!
  • Loading branch information
goodboy committed May 12, 2023
1 parent 34bb787 commit f6dd473
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tractor/_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ async def open_context(

self,
func: Callable,
allow_overruns: bool = False,
**kwargs,

) -> AsyncGenerator[tuple[Context, Any], None]:
Expand Down Expand Up @@ -409,6 +410,16 @@ async def open_context(
fn_mod_path,
fn_name,
kwargs,

# NOTE: it's imporant to expose this since you might
# get the case where the parent who opened the context does
# not open a stream until after some slow startup/init
# period, in which case when the first msg is read from
# the feeder mem chan, say when first calling
# `Context.open_stream(allow_overruns=True)`, the overrun condition will be
# raised before any ignoring of overflow msgs can take
# place..
allow_overruns=allow_overruns,
)

assert ctx._remote_func_type == 'context'
Expand Down

0 comments on commit f6dd473

Please sign in to comment.