Hello Everyone,

Following is my Django application configuration:


*django = 2.2.11djangorestframework = 3.9.2*
*Python = 3.8.2*

I am exposing a set of rest apis for react js frontend, which connects to
Postgres using a layered architecture *views (controller) - services -
data_layer. *In data layer I fetch the data using *Connection.Cursor, *then
transform the data fetched using *cursor.fetchall.*

By default the rest apis are synchronous apis, I am trying to find a way to
make them Async, so that system scalability can be increased,
otherwise every call will block the main thread.

I have tried the following options:

1. Using *asyncio* library, but I am unable to make the complete call chain
Async. I generally get an error that expected return was Response /
HttpResponse, but the method is returning Co-routine. I can find examples
which contains running simple methods as async, but there's isn't an
example of Django Rest API

2. Tried the following link,
https://hackernoon.com/how-to-run-asynchronous-web-requests-in-parallel-with-python-3-5-without-aiohttp-264dc0f8546,
which use the Threadpool executor to segregate every call on a thread in
the controller itself, though the challenge is where to make the Asyncio
call in the Main method as shown in the link, since these APIs are
externally invoked.

3. Can aiohttp help, not sure, but if anyone has an example otherwise I
have to resort to service broker design using an intermediary like Redis
which in my view is unrequired complexity.

Any help / link on the topic would be appreciated.

Thanks,

Mrinal

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPSS-O%2Bm2vOS6D7c_fNFNDccmxBVMJqQZ58bNUtrjTd42Jdf%3Dw%40mail.gmail.com.

Reply via email to