def _tar_stream_close(**kwargs):
"""This is a special function to finish a tar_stream-based
request in the event of an exception."""
tar_stream = cherrypy.request.tar_stream
if tar_stream:
try:
# Attempt to close the tar_stream now that we
# are done processing the request.
tar_stream.close()
except Exception:
# All exceptions are intentionally caught as
# this is a failsafe function and must happen.
# tarfile most likely failed trying to flush
# its internal buffer. To prevent tarfile from
# causing further exceptions during __del__,
# we have to lie and say the fileobj has been
# closed.
tar_stream.fileobj.closed = True
cherrypy.log("Request aborted: ",
traceback=True)
cherrypy.request.tar_stream = None
评论列表
文章目录