From fe611a2bc1c40e388f39fbeb247ba9c10ca24a76 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 3 Jul 2020 17:40:37 -0400 Subject: [PATCH] Allow marking `asyncio` funcs declaring `to_trio` channel --- tractor/_streaming.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tractor/_streaming.py b/tractor/_streaming.py index 9ed0f14..6911731 100644 --- a/tractor/_streaming.py +++ b/tractor/_streaming.py @@ -41,9 +41,11 @@ def stream(func): """ func._tractor_stream_function = True sig = inspect.signature(func) - if 'ctx' not in sig.parameters: + params = sig.parameters + if 'ctx' not in params and 'to_trio' not in params: raise TypeError( "The first argument to the stream function " - f"{func.__name__} must be `ctx: tractor.Context`" + f"{func.__name__} must be `ctx: tractor.Context` " + "(Or ``to_trio`` if using ``asyncio`` in guest mode)." ) return func