You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's an error in the api.py file in the fastapi.
Here's the error:
in Onboarding Flow' - Created task run 'Enroll [email protected] in Onboarding Flow' for task 'enroll_in_onboarding_flow'
api-1 | 22:30:45.656 | INFO | prefect.tasks - Created task run 'populate_workspace'. View it in the UI at 'http://prefect:4200/runs/task-run/1a76e005-c48d-45d3-84a8-a6e23c4de347'
api-1 | Exception in ASGI application
api-1 | Traceback (most recent call last):
api-1 | File "/usr/local/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 412, in run_asgi
api-1 | result = await app( # type: ignore[func-returns-value]
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/usr/local/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
api-1 | return await self.app(scope, receive, send)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/usr/local/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
api-1 | await super().__call__(scope, receive, send)
api-1 | File "/usr/local/lib/python3.12/site-packages/starlette/applications.py", line 123, in __call__
api-1 | await self.middleware_stack(scope, receive, send)
api-1 | File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 186, in __call__
api-1 | raise exc
api-1 | File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 164, in __call__
api-1 | await self.app(scope, receive, _send)
api-1 | File "/usr/local/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 65, in __call__
api-1 | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
api-1 | File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
api-1 | raise exc
api-1 | File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
api-1 | await app(scope, receive, sender)
api-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 754, in __call__
api-1 | await self.middleware_stack(scope, receive, send)
api-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 774, in app
api-1 | await route.handle(scope, receive, send)
api-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 295, in handle
api-1 | await self.app(scope, receive, send)
api-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 77, in app
api-1 | await wrap_app_handling_exceptions(app, request)(scope, receive, send)
api-1 | File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
api-1 | raise exc
api-1 | File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
api-1 | await app(scope, receive, sender)
api-1 | File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 74, in app
api-1 | response = await f(request)
api-1 | ^^^^^^^^^^^^^^^^
api-1 | File "/usr/local/lib/python3.12/site-packages/fastapi/routing.py", line 297, in app
api-1 | raw_response = await run_endpoint_function(
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/usr/local/lib/python3.12/site-packages/fastapi/routing.py", line 210, in run_endpoint_function
api-1 | return await dependant.call(**values)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/fastapi_user_signups/api.py", line 21, in create_user
api-1 | await asyncio.gather(
api-1 | ^^^^^^^^^^^^^^^
api-1 | File "/usr/local/lib/python3.12/asyncio/tasks.py", line 831, in gather
api-1 | fut = ensure_future(arg, loop=loop)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/usr/local/lib/python3.12/asyncio/tasks.py", line 689, in ensure_future
api-1 | raise TypeError('An asyncio.Future, a coroutine or an awaitable '
api-1 | TypeError:
Here's an explanation.
The error occurs because tasks.send_confirmation_email.delay() (and the other task delays) don't return coroutines that can be awaited.
In Prefect, the .delay() method is used to schedule a task for execution, but it's not meant to be awaited. You're trying to use asyncio.gather() with these non-awaitable task schedules.
There's an error in the api.py file in the fastapi.
Here's the error:
Here's an explanation.
The error occurs because
tasks.send_confirmation_email.delay()
(and the other task delays) don't return coroutines that can be awaited.In Prefect, the
.delay()
method is used to schedule a task for execution, but it's not meant to be awaited. You're trying to useasyncio.gather()
with these non-awaitable task schedules.Here's how to fix the code:
The key changes:
asyncio.gather()
since it's not needed.delay()
on each task without awaiting themThis matches the intention described in the README:
The tasks are meant to be "fire-and-forget" - they should be queued up to run asynchronously without the API request waiting for them to complete.
The text was updated successfully, but these errors were encountered: