Skip to content

ResourceWarnings in test_importlib in select buildbots #138313

@jaraco

Description

@jaraco

In #132947 (comment) and the subsequent investigation, we learned that the recent changes to importlib.metadata cause ResourceWarnings to be emitted, causing select buildbot runs to fail.

After extensive investigation and code bisection, the ultimate cause is still not known. The problem has been temporarily remedied by bypassing a test that triggers the failure, but a more permanent solution is needed.

Here's a summary of the situation:

  • The resource warning is caused by an open handle on the test_packages_distributions_example2

    def test_packages_distributions_example2(self):
    """
    Test packages_distributions on a wheel built
    by trampolim.
    """
    self._fixture_on_path('example2-1.0.0-py3-none-any.whl')
    assert packages_distributions()['example2'] == ['example2']

    That seems to implicate something holding onto that zip file, which gets added to sys.path during fixture setup.

  • The resource warning isn't triggered until test_importlib completes.

  • The warning is only emitted in a few buildbots, but not on local tests, GHA tests, or other buidlbots.

  • The changes in importlib.metadata.__init__ seem to be implicated, but even after removing nearly every change in that file, the problem remained.

Testing using buildbot is slow and tedious. Probably the next best step is to find a way to replicate the issue in a development environment, either by getting access to a buildbot image or by creating a comparable image that replicates the issue.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtopic-importlibtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions