HH-45061 backport write_error from tornado3