Skip to content
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

Fix DeprecationWarning: connections() is deprecated and will be removed; use net_connections() instead #1206

Open
mukund-ananthu opened this issue Jun 19, 2024 · 0 comments
Assignees
Labels
api: pubsub Issues related to the googleapis/python-pubsub API.

Comments

@mukund-ananthu
Copy link
Contributor

___________ test_subscriber_not_leaking_open_sockets[rest-rest-rest] ___________

publisher = 
topic_path_base = 'projects/<REDACTED>/topics/<REDACTED>'
subscription_path_base = 'projects/<REDACTED>/subscriptions/<REDACTED>'
cleanup = [(>, (), {'topic': 'projects/<REDACTED>/topics/<REDACTED>'})]
transport = 'rest'

    @pytest.mark.parametrize("transport", ["grpc", "rest"])
    def test_subscriber_not_leaking_open_sockets(
        publisher, topic_path_base, subscription_path_base, cleanup, transport
    ):
        # Make sure the topic and the supscription get deleted.
        # NOTE: Since subscriber client will be closed in the test, we should not
        # use the shared `subscriber` fixture, but instead construct a new client
        # in this test.
        # Also, since the client will get closed, we need another subscriber client
        # to clean up the subscription. We also need to make sure that auxiliary
        # subscriber releases the sockets, too.
        custom_str = "-not-leaking-open-sockets"
        subscription_path = subscription_path_base + custom_str
        topic_path = topic_path_base + custom_str
        subscriber = pubsub_v1.SubscriberClient(transport="grpc")
        subscriber_2 = pubsub_v1.SubscriberClient(transport="grpc")
    
        cleanup.append(
            (subscriber_2.delete_subscription, (), {"subscription": subscription_path})
        )
        cleanup.append((subscriber_2.close, (), {}))
        cleanup.append((publisher.delete_topic, (), {"topic": topic_path}))
    
        # Create topic before starting to track connection count (any sockets opened
        # by the publisher client are not counted by this test).
        publisher.create_topic(name=topic_path)
    
        current_process = psutil.Process()
>       conn_count_start = len(current_process.connections())

tests/system.py:471: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = psutil.Process(pid=397, name='py.test', status='running', started='16:34:59')
args = (), kwargs = {}

    @functools.wraps(fun)
    def inner(self, *args, **kwargs):
>       warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
E       DeprecationWarning: connections() is deprecated and will be removed; use net_connections() instead
@mukund-ananthu mukund-ananthu self-assigned this Jun 19, 2024
@product-auto-label product-auto-label bot added the api: pubsub Issues related to the googleapis/python-pubsub API. label Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/python-pubsub API.
Projects
None yet
Development

No branches or pull requests

1 participant