diff --git a/pygeoapi/api.py b/pygeoapi/api.py index 7a12032..1e139f2 100644 --- a/pygeoapi/api.py +++ b/pygeoapi/api.py @@ -358,18 +358,14 @@ class APIRequest: # Set data from Django request api_req._data = request.body else: - try: - import nest_asyncio - nest_asyncio.apply() - # Set data from Starlette request after async - # coroutine completion - # TODO: - # this now blocks, but once Flask v2 with async support - # has been implemented, with_data() can become async too - loop = asyncio.get_event_loop() - api_req._data = loop.run_until_complete(request.body()) - except ModuleNotFoundError: - LOGGER.error('Module nest-asyncio not found') + # Set data from Starlette request after async + # coroutine completion + # TODO: + # this now blocks, but once Flask v2 with async support + # has been implemented, with_data() can become async too + loop = asyncio.get_event_loop() + api_req._data = asyncio.run_coroutine_threadsafe( + request.body(), loop) return api_req @staticmethod diff --git a/requirements-starlette.txt b/requirements-starlette.txt index b0ed6cc..35e6425 100644 --- a/requirements-starlette.txt +++ b/requirements-starlette.txt @@ -1,4 +1,3 @@ aiofiles starlette uvicorn[standard] -nest-asyncio