Skip to content

Conversation

@Fan-iX
Copy link

@Fan-iX Fan-iX commented Sep 8, 2025

Hi,

I use a python web server to serve gff data with gffutils.

In my application, a FeatureDB instance is created on every web request, and I notice that I have to .close() the FeatureDB.conn explictly, or there could be a file descriptor leak / memory leak.

This PR add context manager methods __enter__ and __exit__ to the FeatureDB class, so that we can manage it within a with statement:

with sqlite3.FeatureDB("test.gff.db") as db:
    ...

instead of

try:
    db = sqlite3.FeatureDB("test.gff.db")
    ...
finally:
    db.conn.close()

This PR add context manager methods `__enter__` and `__exit__` to the FeatureDB class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant