Skip to content

Fix an issue where the _thirdparty package is not distributed correctly #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2021

Conversation

Hazhzeng
Copy link
Contributor

@Hazhzeng Hazhzeng commented Jun 3, 2021

Description

This is the root cause of the library where the azure.functions._thirdparty sub-folder failed to reload properly.
The dangling _thirdparty folder is not being treated as a proper Python module.
Thus, when poping out from sys.modules, it is not being recognized as a part of azure.functions. Thus, the topology graph is not built out correctly when removing caches from sys.modules.

Related PR

Azure/azure-functions-python-worker#854

See how azure_functions_worker distribute the _thirdparty package properly

It has __init__.py file defined in it: https://github.com/Azure/azure-functions-python-worker/tree/dev/azure_functions_worker/_thirdparty
It is being included in setup.py: https://github.com/Azure/azure-functions-python-worker/blob/dev/setup.py#L389

How this is found

Using this following code for reloading module.

try:
    module_paths = set(getattr(module, '__path__', None) or [])
    if hasattr(module, '__file__') and module.__file__:
        module_paths.add(module.__file__)

    if any([p for p in module_paths if p.startswith(path)]):
        sys.modules.pop(module_name)
except Exception as e:
    logger.warning(
        f'Attempt to remove module cache for {module_name} but'
        f' failed with {e}. Using the original module cache.'
    )

Failed with
Attempt to remove module cache for azure.functions._thirdparty but failed with 'azure.functions'. Using the original module cache.

More to investigate

I'm not quite sure why this is triggered when the module is hot-reloaded (a.k.a. Linux Consumption). This should also fail in D

@github-actions
Copy link

github-actions bot commented Jun 3, 2021

✅ Result of Pytest Coverage

Copy link
Member

@vrdmr vrdmr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Hazhzeng Hazhzeng merged commit 9d7a037 into dev Jun 3, 2021
@Hazhzeng Hazhzeng deleted the hazeng/fix-third-party-package branch June 3, 2021 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants