Skip to content

ResourceWarning: unclosed SSLSocket #29227

@parthea

Description

@parthea

What version of gRPC and what language are you using?

grpcio==1.44.0.
Python

What operating system (Linux, Windows,...) and version?

Linux (Google)

What runtime / compiler are you using (e.g. python version or version of gcc)

Python 3.9.9

gcc --version
gcc (Debian 11.2.0-16) 11.2.0

What did you do?

Please provide either 1) A unit test for reproducing the bug or 2) Specific steps for us to follow to reproduce the bug. If there’s not enough information to debug the problem, gRPC team may close the issue at their discretion. You’re welcome to re-open the issue once you have a reproduction.
I ran the code example from this issue.

What did you expect to see?

I didn't expect to see warnings.

What did you see instead?

I saw a similar warning as reported this issue.

.../lib/python3.8/site-packages/grpc/_channel.py:1548: ResourceWarning: unclosed <ssl.SSLSocket fd=10, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=6, laddr=('2a02:1210:22bd:8300:2b23:d126:3a74:f57b', 46782, 0, 0), raddr=('2a00:1450:400a:801::200a', 443, 0, 0)>
  self._channel.close(cygrpc.StatusCode.cancelled, 'Channel closed!')
ResourceWarning: Enable tracemalloc to get the object allocation traceback

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

See TROUBLESHOOTING.md for how to diagnose problems better.

Anything else we should know about your project / environment?

I'm able to reproduce the issue every time. I also tried debugging and wrapping the code in contextlib.closing but the warning persisted.

with contextlib.closing(secretmanager.SecretManagerServiceClient()) as client:
        response = client.create_secret(
            request={
                "parent": parent,
                "secret_id": "test2",
                "secret": {"replication": {"automatic": {}}},
            }
        )

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions