Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
331 stars 100 forks source link

[BUG] Azure Func Python Library: AppExtensionBase - potential small memory leak #1500

Open macieyng opened 1 month ago

macieyng commented 1 month ago

I'm referring to this code https://github.com/Azure/azure-functions-python-library/blob/dev/azure/functions/extension/app_extension_base.py#L65-L70

    @classmethod
    def pre_invocation_app_level(cls,
                                 logger: Logger,
                                 context: Context,
                                 func_args: typing.Dict[str, object] = {},
                                 *args,
                                 **kwargs) -> None:

and line func_args: typing.Dict[str, object] = {}, is troubling me, because code initializes default argument with mutable type. AFAIK that can cause a memory leak in general (https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments), but maybe in the context how it's run it's not a problem.

Not sure if this is a real problem. My app has some memory leaks, but it's not that painful, so I wasn't investigating it much.