Skip to content

Tests and examples are not using the WITH Python clause #2061

@wernerdaehn

Description

@wernerdaehn

I just followed the examples of how to produce/consume data with Python and got the message

ResourceWarning: unclosed <socket.socket fd=1152, family=2, type=1, proto=0, laddr=('...', 51820), raddr=('...', 8081)>

which is clearly the schema registry not closing everything. And it does not have a close method in contrast to the producer. Upon reading the source code, I found it contains a __exit__ method, meaning it is enabled to be used with a WITH clause. So the proper way should be

with SchemaRegistryClient(self.settings.schema_registry_config) as schema_registry_client:

and not what is being used in the examples.

schema_registry_client = SchemaRegistryClient(schema_registry_conf)

Would be good to educate all by modifying the examples. Frankly, I would love to use producers/consumers/admin_client also with a WITH clause.

Metadata

Metadata

Assignees

Labels

code:pythonIssues that are specific to Python or versions of Python independent of library logicdocsRequesting a documentation changepriority:highMaintainer triage tag for indicating high impact or criticality issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions