Skip to content

Commit f0638f4

Browse files
Removed the dependency on nest-asyncio (#1493)
1 parent 62b8d67 commit f0638f4

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

Diff for: pygeoapi/api.py

+8-12
Original file line numberDiff line numberDiff line change
@@ -358,18 +358,14 @@ def with_data(cls, request, supported_locales) -> 'APIRequest':
358358
# Set data from Django request
359359
api_req._data = request.body
360360
else:
361-
try:
362-
import nest_asyncio
363-
nest_asyncio.apply()
364-
# Set data from Starlette request after async
365-
# coroutine completion
366-
# TODO:
367-
# this now blocks, but once Flask v2 with async support
368-
# has been implemented, with_data() can become async too
369-
loop = asyncio.get_event_loop()
370-
api_req._data = loop.run_until_complete(request.body())
371-
except ModuleNotFoundError:
372-
LOGGER.error('Module nest-asyncio not found')
361+
# Set data from Starlette request after async
362+
# coroutine completion
363+
# TODO:
364+
# this now blocks, but once Flask v2 with async support
365+
# has been implemented, with_data() can become async too
366+
loop = asyncio.get_event_loop()
367+
api_req._data = asyncio.run_coroutine_threadsafe(
368+
request.body(), loop)
373369
return api_req
374370

375371
@staticmethod

Diff for: requirements-starlette.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
aiofiles
22
starlette
33
uvicorn[standard]
4-
nest-asyncio

0 commit comments

Comments
 (0)