We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Add an IOFount class that makes a fount from a readable FLO.
IOFount
The code below works, but it's doing a blocking read on the data, and should be streaming instead.
@implementer(IFount) @attrs(frozen=False) class IOFount(object): """ Fount that reads from a file-like-object. """ outputType = ISegment _source = attrib() # type: BinaryIO drain = attrib( validator=optional(provides(IDrain)), default=None, init=False ) # type: IDrain _paused = attrib(validator=instance_of(bool), default=False, init=False) def __attrs_post_init__(self): # type: () -> None self._pauser = Pauser(self._pause, self._resume) def _flowToDrain(self): # type: () -> None if self.drain is not None and not self._paused: data = self._source.read() if data: self.drain.receive(data) self.drain.flowStopped(Failure(StopIteration())) # FIXME: this should stream. def flowTo(self, drain): # type: (IDrain) -> IFount result = beginFlowingTo(self, drain) self._flowToDrain() return result def pauseFlow(self): # type: () -> None return self._pauser.pause() def stopFlow(self): # type: () -> None return self._pauser.resume() def _pause(self): # type: () -> None self._paused = True def _resume(self): # type: () -> None self._paused = False self._flowToDrain()
The text was updated successfully, but these errors were encountered:
Wouldn't this be better named "FileFount"?
Sorry, something went wrong.
@glyph: perhaps. I was borrowing the BinaryIO and TextIO stdlib conventions for "I/O streams" which include but aren't limited to files…
BinaryIO
TextIO
Hm; that works I guess.
No branches or pull requests
Add an
IOFount
class that makes a fount from a readable FLO.The code below works, but it's doing a blocking read on the data, and should be streaming instead.
The text was updated successfully, but these errors were encountered: