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

Allow using plyvel.DB as a context manager #151

Merged
merged 1 commit into from
Mar 10, 2023
Merged

Allow using plyvel.DB as a context manager #151

merged 1 commit into from
Mar 10, 2023

Conversation

Necklaces
Copy link
Contributor

@Necklaces Necklaces commented Mar 9, 2023

Allows for using with on plyvel.DB, like this:

with plyvel.DB(...) as db:
    ...

I'm not too familiar with the codebase, but I added a test and it seems to work.

test/test_plyvel.py Outdated Show resolved Hide resolved
@wbolster
Copy link
Owner

wbolster commented Mar 9, 2023

thanks, lgtm mostly. left a few comments.

note that you can already do this today using contextlib.closing() from the python stdlib

@wbolster wbolster changed the title Add __enter__ and __exit__ in plyvel.DB Allow using plyvel.DB as a context manager Mar 9, 2023
@Necklaces
Copy link
Contributor Author

Neat, I might've been a little too fast so those were great suggestions.

I amended the commit with those changes to keep history clean

@wbolster wbolster merged commit fc99b8e into wbolster:main Mar 10, 2023
@wbolster
Copy link
Owner

thanks, lgtm. merged

wbolster added a commit that referenced this pull request Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants