0

Actually I want to return a response whenever a request is fired and then execute the task asynchronously so that the client has to not wait for a long to get the response.For that, I am using "Aiohttp" library as I want to perform async tasks.

Can anyone guide me on how can i achieve this in aiohttp?

petezurich
  • 9,280
  • 9
  • 43
  • 57
jack
  • 101
  • 1
  • 9
  • There're examples from official site: https://github.com/aio-libs/aiohttp Is there anything specific you want to know? – knh190 Jun 18 '19 at 09:46
  • Yes knh190 , actually in the given examples on the official documentation or the link that you mentioned , they return the web_response after the execution of the task.But, suppose your task is quite long and if a client fires a request , then the client has to wait a long for receiving the response and instead what I want is that as soon as the request is fired , the reponse is sent to the client and task is added to the eventloop for execution and it takes its time then. – jack Jun 18 '19 at 09:50
  • The response is async. It's not blocking the execution of main loop. So I don't see there a problem. For more explained details about coroutines, see [this post](https://github.com/AndreLouisCaron/a-tale-of-event-loops) and [this](https://stackoverflow.com/questions/553704/what-is-a-coroutine) for brief. – knh190 Jun 18 '19 at 09:54
  • `httpio` is made for the purpose of executing non-blocking requests. The execution will be handed over to main loop when waiting for a response, without trivial coding. – knh190 Jun 18 '19 at 09:58
  • ok , thanks for the help. I'll try if I get the correct solution from this. – jack Jun 18 '19 at 10:07
  • `aiojobs` will help you (https://github.com/aio-libs/aiojobs) – Yurii Kramarenko Jun 19 '19 at 13:14

0 Answers0