shut down immediately on disk full error

This commit is contained in:
Noah Levitt 2017-03-28 12:39:41 -07:00
parent 73d934d0a4
commit 1c035153de
2 changed files with 14 additions and 3 deletions

View File

@ -51,7 +51,7 @@ except:
setuptools.setup(
name='warcprox',
version='2.1b1.dev61',
version='2.1b1.dev62',
description='WARC writing MITM HTTP/S proxy',
url='https://github.com/internetarchive/warcprox',
author='Noah Levitt',

View File

@ -39,6 +39,7 @@ import hanzo.httptools
from hanzo import warctools
import warcprox
import cProfile
import sys
class WarcWriterThread(threading.Thread):
logger = logging.getLogger("warcprox.warcproxwriter.WarcWriterThread")
@ -102,8 +103,18 @@ class WarcWriterThread(threading.Thread):
self.logger.info('WarcWriterThread shutting down')
self.writer_pool.close_writers()
except:
self.logger.critical("WarcWriterThread will try to continue after unexpected error", exc_info=True)
except BaseException as e:
if isinstance(e, OSError) and e.errno == 28:
# OSError: [Errno 28] No space left on device
self.logger.critical(
'shutting down due to fatal problem: %s: %s',
e.__class__.__name__, e)
self.writer_pool.close_writers()
sys.exit(1)
self.logger.critical(
'WarcWriterThread will try to continue after unexpected '
'error', exc_info=True)
time.sleep(0.5)
# closest thing we have to heritrix crawl log at the moment