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

💡 Feature Proposal: Add a way to clean up after a lazy Source.get_records() generator is abandoned #442

Open
aaronsteers opened this issue Nov 6, 2024 · 0 comments

Comments

@aaronsteers
Copy link
Contributor

Today, the Source.get_records() method returns a LazyDataset that can be iterated upon to get records.

Given a source declared like this:

import airbyte as ab

source = ab.get_source(...)

You can iterate over records lazily like this:

max_records = 10

dataset: ab.LazyDataset = source.get_records("my_stream")
for record, x in enumerate(dataset):
    if x > max_records:
        break
    print(record)

This approach uses the dataset as an iterator and then aborts after the necessary count of records is found.

However, the connector process itself is not shut down when we stop iterating from it.

Improvement Proposal

Ideally, we'd add a callback to close the connection on the lazy dataset - and/or we'd operate like a context manager and auto-clean up the process when the context manager exits.

In practice, this has not caused any problems for our use cases - but it would be good to improve handling here.

@aaronsteers aaronsteers changed the title 💡 Feature Request: The lazy Source.get_records() generator method doesn't yet have a clean way to shut down the connector process 💡 Feature Proposal: Add a way to clean up after a lazy Source.get_records() generator method is abandoned Nov 6, 2024
@aaronsteers aaronsteers changed the title 💡 Feature Proposal: Add a way to clean up after a lazy Source.get_records() generator method is abandoned 💡 Feature Proposal: Add a way to clean up after a lazy Source.get_records() generator is abandoned Nov 6, 2024
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

No branches or pull requests

1 participant