From 03c1b0009c4b53eccc568ed939bfe1ef654a156f Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Mon, 26 Nov 2018 02:29:56 +0000 Subject: [PATCH] Fix 'Too many open files' error. Happened before after continuous archiving of few hundreds links. Fix by: * setting process object to `None` to trigger GC finalizer cleanup of pipe descriptors * protecting against double cleanup --- archiver/util.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/archiver/util.py b/archiver/util.py index 14f8ccff..e4c7dbe3 100644 --- a/archiver/util.py +++ b/archiver/util.py @@ -161,7 +161,13 @@ def progress(seconds=TIMEOUT, prefix=''): def end(): """immediately finish progress and clear the progressbar line""" + nonlocal p + if p is None: # protect from double termination + return + p.terminate() + p = None + sys.stdout.write('\r{}{}\r'.format((' ' * TERM_WIDTH), ANSI['reset'])) # clear whole terminal line sys.stdout.flush()