summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpidu30
1 files changed, 18 insertions, 12 deletions
diff --git a/pidu b/pidu
index 52ce2f2..1f5bece 100755
--- a/pidu
+++ b/pidu
@@ -2,6 +2,11 @@
import sys, os, argparse
from multiprocessing import Process, JoinableQueue, Queue, cpu_count
+# Don't display big traceback on file permission problems and so
+def exc_oneline():
+ (exception_type, exception, traceback) = sys.exc_info()
+ print("%s: %s" % (exception_type.__name__, exception), file=sys.stderr)
+
# Forked process main proc
def proc_du(q_in,counters_count, q_out):
# Sum up all files' 512-byte blocks allocated
@@ -12,19 +17,20 @@ def proc_du(q_in,counters_count, q_out):
if special == 'done':
break
try:
- for it in os.scandir(path):
- # Sum up file or folder physicial size (in blocks) to local_counters
- local_counters[counter_indice] += it.stat(follow_symlinks=False).st_blocks
- # Put more work on queue (could be taken by an other process)
- if it.is_dir(follow_symlinks=False):
- q_in.put( (it.path, counter_indice, None) )
+ for entry in os.scandir(path):
+ try:
+ # Sum up file or folder physicial size (in blocks) to local_counters
+ local_counters[counter_indice] += entry.stat(follow_symlinks=False).st_blocks
+ # Put more work on queue (could be taken by an other process)
+ if entry.is_dir(follow_symlinks=False):
+ q_in.put( (entry.path, counter_indice, None) )
+ except:
+ exc_oneline()
except:
- # Don't display big traceback on file permission problems and so
- (exception_type, exception, traceback) = sys.exc_info()
- print("%s: %s" % (exception_type.__name__, exception), file=sys.stderr)
- finally:
- # Go next file or folder even if current can't be treated
- q_in.task_done()
+ exc_oneline()
+
+ # Go next file or folder even if current can't be treated
+ q_in.task_done()
# After receiving special 'done' message, put results back into q_out
q_out.put(local_counters)