botbuilder-python icon indicating copy to clipboard operation
botbuilder-python copied to clipboard

Always Create `aiohttp.ClientSession` in a Running Loop

Open Zerryth opened this issue 5 years ago • 0 comments

Related to issue#1187.

  • Workaround implemented in PR#1369 that allows users who use frameworks that don't wrap their requests in a running "ProactorEventLoop" to pass in python's built-in requests module as QnAMaker._http_client.

Filing an issue per email conversation with Axel and Dave T.:

so that we follow the pattern that’s closer to what’s happening in LUIS: • If they pass in an http client on init, then use that • Otherwise instead of creating the aiohttp.ClientSession instance in the ctor like we do currently (which is not a coroutine), we should do it in the HttpRequestUtils.execute_http_request method (where it is async), where we make the actual POST request to QnA service

And I think with that, this should remove the need for Quart projects to have to pass in http_client too.

The above should allow more python frameworks to continue using aiohttp to make requests, which is asynchronous, instead of being forced to use synchronous requests module.

Zerryth avatar Aug 28 '20 18:08 Zerryth