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

a closed parameter for SourceReader #6

Open
thorwhalen opened this issue Jan 5, 2021 · 4 comments
Open

a closed parameter for SourceReader #6

thorwhalen opened this issue Jan 5, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@thorwhalen
Copy link
Member

thorwhalen commented Jan 5, 2021

In stream2py objects, is there a way to check if a stream is open?

io.IOBase (so, subclasses that you probably use regularly (when opening a file etc)) has a close (which stream2py.source_reader.SourceReader has), but also has a closed (which SourceReader doesn't).

Would be useful to have one.

┆Issue is synchronized with this Asana task by Unito

@thorwhalen thorwhalen added the enhancement New feature or request label Jan 5, 2021
@andeaseme
Copy link
Member

andeaseme commented Jan 5, 2021

StreamBuffer and BufferReader each have a property to tell if the source is running or stopped.
https://i2mint.github.io/stream2py/api.html#stream2py.BufferReader.is_stopped
https://i2mint.github.io/stream2py/api.html#stream2py.StreamBuffer.is_running

Is this what you need or is there any added value of having a closed parameter?

@thorwhalen
Copy link
Member Author

The added value of consistency with the builtin io interface, if and when the correspondence makes sense.

We don't need to subclass io.BaseIO (which I've always found awkward to deal with, and comes with many methods that are not meant for general streams). But closed seems to have a fairly consistent meaning.

Perhaps it's just a matter of putting a

closed = property(BufferReader.is_stopped)  # alias to be consistent with `io` interface

and the same in StreamBuffer.

Shouldn't we have this in SourceReader as well? Defaulted to True? Required?

@andeaseme
Copy link
Member

Adding closed property is good for consistency. And also rename StreamBuffer's start and stop to open and close. And add a deprecation warning for start, stop, is_running, is_stopped.

Shouldn't we have this in SourceReader as well? Defaulted to True? Required?

I don't see any significant value in adding closed to SourceReader since the intent is to only have StreamBuffer interacting with SourceReader so any added properties and methods would not be used.

@thorwhalen
Copy link
Member Author

Assigned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants