-
-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Starlette server fails with top level async-await #1964
Labels
bug
Something isn't working
Comments
A similar issue is generated if you try to use the EDR provider instead of the OAF provider for a plugin. It appears in both cases a coroutine is not being awaited properly @BaseEDRProvider.register()
async def area(
self,
wkt: str,
select_properties: list[str] = [],
datetime_: Optional[str] = None,
z: Optional[str] = None,
format_: Optional[str] = None,
**kwargs,
):
await asyncio.sleep(1)
# .... rest of valid covjson response omitted here for brevity; but it doesn't get beyond the sleep regardless
|
@francbartoli @ricardogsilva interested to hear you experience developing async within pygeoapi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
When launching pygeoapi with
pygeoapi serve --starlette
pygeoapi throws an error if you try to use top level async functions.I expected to be able to use async functions without needing to use
asyncio.run
since the web server should initialize the async event loop.If you are developing a large pygeoapi plugin with lots of fetch-based ETL, async is often needed and using
asyncio.run
over every async function adds a fair bit of boilerplate (and requires you to make sure another event loop isn't running / created by another plugin)The error seems to signify that the content is not being awaited properly
Steps to Reproduce
get
inside the providerget()
it will give the error:Expected behavior
I expect to be able to have starlette itself initialize the async event loop. I expected to be able to use async functions as it mentions in the starlette docs
Environment
pygeoapi, version 0.20.dev0
The text was updated successfully, but these errors were encountered: