Conditions | 2 |
Total Lines | 28 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | """Leaf definition.""" |
||
10 | def action(target: CallableFunction, **kwargs) -> AsyncInnerFunction: |
||
11 | """Declare an action leaf. |
||
12 | |||
13 | Action is an awaitable closure of specified function, |
||
14 | (See alias function). |
||
15 | |||
16 | Args: |
||
17 | target (CallableFunction): awaitable function |
||
18 | kwargs: optional kwargs argument to pass on target function |
||
19 | |||
20 | Returns: |
||
21 | (AsyncInnerFunction): an awaitable function. |
||
22 | |||
23 | Raises: |
||
24 | ControlFlowException : if error occurs |
||
25 | |||
26 | """ |
||
27 | |||
28 | _target = to_async(target) |
||
29 | |||
30 | @node_metadata(properties=['_target']) |
||
31 | async def _action(): |
||
32 | try: |
||
33 | return await _target(**kwargs) |
||
34 | except Exception as e: |
||
35 | raise ControlFlowException.instanciate(e) |
||
36 | |||
37 | return _action |
||
38 | |||
54 |