Expose `allow_overruns` to `Portal.open_context()`

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!
ctx_cancel_semantics_and_overruns
Tyler Goodlet 2023-05-12 18:28:47 -04:00
parent 60791ed546
commit ead9e418de
1 changed files with 11 additions and 0 deletions

View File

@ -380,6 +380,7 @@ class Portal:
self,
func: Callable,
allow_overruns: bool = False,
**kwargs,
) -> AsyncGenerator[tuple[Context, Any], None]:
@ -409,6 +410,16 @@ class Portal:
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'