dispatchrun / dispatch-py

Python package to develop applications with Dispatch.
https://pypi.org/project/dispatch-py/
Apache License 2.0
54 stars 3 forks source link

Fail early when awaiting on non-async functions #85

Closed Pryz closed 6 months ago

Pryz commented 7 months ago

Currently, if you await on a non-async function, like:

@dispatch.function
def fn():
   ...

@dispatch.function
def main():
  await fn()

We will go through the execution until we hit:

unexpected exception occurred during coroutine scheduling
Traceback (most recent call last):
  File "/Users/julienfabre/code/github.com/local/examples/.venv/lib/python3.11/site-packages/dispatch/scheduler.py", line 162, in run
    return self._run(input)
           ^^^^^^^^^^^^^^^^
  File "/Users/julienfabre/code/github.com/local/examples/.venv/lib/python3.11/site-packages/dispatch/scheduler.py", line 317, in _run
    g = awaitable.__await__()
        ^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute '__await__'