def read(self, n=65536):
"""
Called when it is detected the input side of this connector is ready
to read. Reads at most n bytes and writes them to the output ends of
this connector. If no bytes could be read, the connector is closed.
:param n The maximum number of bytes to read.
:type n int
:returns: The actual number of bytes read.
"""
buf = self.input.read(n)
if buf:
self.output.write(buf)
# TODO PushAdapter/Writers should return number of bytes actually
# written.
return len(buf)
else:
self.close()
return 0
评论列表
文章目录