def write(self, n=65536):
"""
Called when it is detected the output side of this connector is ready
to write. Reads (potentially blocks) 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 write.
:type n int
:returns: The actual number of bytes written.
"""
buf = self.input.read(n)
if buf:
return self.output.write(buf)
else:
self.close()
return 0
评论列表
文章目录