Skip to content

Calling instance_ip_grouping_key leads to a ResourceWarning on Python 3.4 #51

@andersschuller

Description

@andersschuller

I noticed this when working on fixing #46. When I run python3 setup.py test, I get the following warning in the test output:

test_instance_ip_grouping_key (tests.test_client.TestPushGateway) ... tests/test_client.py:478: ResourceWarning: unclosed <socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('127.0.0.1', 58422)>
self.assertTrue('' != instance_ip_grouping_key()['instance'])

I can also reproduce this warning outside of the tests by running python3 -Wdefault and then calling instance_ip_grouping_key.

Should this function explicitly close the socket it opens instead of relying on it to be cleaned up automatically?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions