Returns the automatic executor of Pathway Live Data Framework UDF. It deduces whether the execution should be synchronous or asynchronous from the function signature. If the function is a coroutine, then the execution is asynchronous. Otherwise, it is synchronous. Example: >>>
()
| 46 | |
| 47 | |
| 48 | def auto_executor() -> Executor: |
| 49 | """ |
| 50 | Returns the automatic executor of Pathway Live Data Framework UDF. It deduces whether the execution |
| 51 | should be synchronous or asynchronous from the function signature. If the function |
| 52 | is a coroutine, then the execution is asynchronous. Otherwise, it is synchronous. |
| 53 | |
| 54 | Example: |
| 55 | |
| 56 | >>> import pathway as pw |
| 57 | >>> import asyncio |
| 58 | >>> import time |
| 59 | >>> t = pw.debug.table_from_markdown( |
| 60 | ... ''' |
| 61 | ... a | b |
| 62 | ... 1 | 2 |
| 63 | ... 3 | 4 |
| 64 | ... 5 | 6 |
| 65 | ... ''' |
| 66 | ... ) |
| 67 | >>> |
| 68 | >>> @pw.udf(executor=pw.udfs.auto_executor()) |
| 69 | ... def mul(a: int, b: int) -> int: |
| 70 | ... return a * b |
| 71 | ... |
| 72 | >>> result_1 = t.select(res=mul(pw.this.a, pw.this.b)) |
| 73 | >>> pw.debug.compute_and_print(result_1, include_id=False) |
| 74 | res |
| 75 | 2 |
| 76 | 12 |
| 77 | 30 |
| 78 | >>> |
| 79 | >>> @pw.udf(executor=pw.udfs.auto_executor()) |
| 80 | ... async def long_running_async_function(a: int, b: int) -> int: |
| 81 | ... await asyncio.sleep(0.1) |
| 82 | ... return a * b |
| 83 | ... |
| 84 | >>> result_2 = t.select(res=long_running_async_function(pw.this.a, pw.this.b)) |
| 85 | >>> pw.debug.compute_and_print(result_2, include_id=False) |
| 86 | res |
| 87 | 2 |
| 88 | 12 |
| 89 | 30 |
| 90 | """ |
| 91 | return AutoExecutor() |
| 92 | |
| 93 | |
| 94 | @dataclass |
nothing calls this directly
no test coverage detected