Removed the dependency on nest-asyncio (#1493)

This commit is contained in:
Ricardo Garcia Silva
2024-01-15 18:52:37 +00:00
committed by GitHub
parent 62b8d67018
commit f0638f445f
2 changed files with 8 additions and 13 deletions
+8 -12
View File
@@ -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
-1
View File
@@ -1,4 +1,3 @@
aiofiles
starlette
uvicorn[standard]
nest-asyncio