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 # Set data from Django request
api_req._data = request.body api_req._data = request.body
else: else:
try: # Set data from Starlette request after async
import nest_asyncio # coroutine completion
nest_asyncio.apply() # TODO:
# Set data from Starlette request after async # this now blocks, but once Flask v2 with async support
# coroutine completion # has been implemented, with_data() can become async too
# TODO: loop = asyncio.get_event_loop()
# this now blocks, but once Flask v2 with async support api_req._data = asyncio.run_coroutine_threadsafe(
# has been implemented, with_data() can become async too request.body(), loop)
loop = asyncio.get_event_loop()
api_req._data = loop.run_until_complete(request.body())
except ModuleNotFoundError:
LOGGER.error('Module nest-asyncio not found')
return api_req return api_req
@staticmethod @staticmethod
-1
View File
@@ -1,4 +1,3 @@
aiofiles aiofiles
starlette starlette
uvicorn[standard] uvicorn[standard]
nest-asyncio