But the new solution does not use and never closes the loop created in the constructor
Expected behavior
Starting an event loop is not trivial and opens file resources. These won't be closed when using the new solution. When using the handle_async method there is no need to start a new event loop. If an event loop is needed for backward compatibility in the deprecated handle method, it should be created and stopped in the deprecated method and not in the init.
Timestamp: Tue 31 Oct 2022 10:45 CET Python azure-functions v1.10
The current AsgiMiddleware class starts a new event loop in its constructor. As can be seen here:
https://github.com/Azure/azure-functions-python-library/blob/8fb366baee8851c6dc1056ccede512694b3bcc70/azure/functions/_http_asgi.py#L149
The deprecated
handle()
method was responsible for closing this loop once a request was handled.A better
handle_async()
method replaced this solution and was introduced here:https://github.com/Azure/azure-functions-python-library/pull/143/files
But the new solution does not use and never closes the loop created in the constructor
Expected behavior
Starting an event loop is not trivial and opens file resources. These won't be closed when using the new solution. When using the handle_async method there is no need to start a new event loop. If an event loop is needed for backward compatibility in the deprecated handle method, it should be created and stopped in the deprecated method and not in the init.