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

Shutdown method: .finalize() #20

Open
jlnav opened this issue Dec 13, 2024 · 1 comment
Open

Shutdown method: .finalize() #20

jlnav opened this issue Dec 13, 2024 · 1 comment

Comments

@jlnav
Copy link
Contributor

jlnav commented Dec 13, 2024

This proposes a new standard method:

finalize()

For those generators that may need to close down connections, dump/complete models, stop background processes, or perform some other computation upon being informed that no more points will be requested.

@jlnav
Copy link
Contributor Author

jlnav commented Jan 15, 2025

Clarifying that we don't advocate for this to only accommodate APOSMM. For "objects that produce data" this is a common but by-no-means required pattern.

Consider that file-handles, database connections, or other objects into which data are read and written commonly have .close() or some equivalent. In Python this is commonly accomplished through context switching with with. This could be possible with generators too.

This .close(), .finalize(), __enter__()/__exit__() or however such a method would be implemented, I don't think this falls under "orchestration" anymore than closing a file orchestrates the data from that file.

I personally am starting to lean towards optional context-switching. Its elegant, pythonic, self-explanatory, and document-able.

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