forked from goodboy/tractor
1
0
Fork 0

Allow marking `asyncio` funcs declaring `to_trio` channel

advanced_debugger_testing
Tyler Goodlet 2020-07-03 17:40:37 -04:00
parent 0adcefcfd4
commit a045ba489a
1 changed files with 4 additions and 2 deletions

View File

@ -41,9 +41,11 @@ def stream(func):
""" """
func._tractor_stream_function = True func._tractor_stream_function = True
sig = inspect.signature(func) 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( raise TypeError(
"The first argument to the stream function " "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 return func