From e410f88926a71a743a1bc988f7042860040f4fdf Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sat, 5 Mar 2011 13:02:11 +0100 Subject: [PATCH] Catch a random occurrence of an exception on multiprocessing.cpu_count() so that dupeGuru doesn't crash because of that. --- core_pe/matchbase.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core_pe/matchbase.py b/core_pe/matchbase.py index b419239c..6e2e0de9 100644 --- a/core_pe/matchbase.py +++ b/core_pe/matchbase.py @@ -41,7 +41,13 @@ MIN_CHUNK_SIZE = 100 # Enough so that we're sure that the main thread will not wait after a result.get() call # cpucount+1 should be enough to be sure that the spawned process will not wait after the results # collection made by the main process. -RESULTS_QUEUE_LIMIT = multiprocessing.cpu_count() + 1 +try: + RESULTS_QUEUE_LIMIT = multiprocessing.cpu_count() + 1 +except Exception: + # I had an IOError on app launch once. It seems to be a freak occurrence. In any case, we want + # the app to launch, so let's just put an arbitrary value. + logging.warning("Had problems to determine cpu count on launch.") + RESULTS_QUEUE_LIMIT = 8 def prepare_pictures(pictures, cache_path, with_dimensions, j=job.nulljob): # The MemoryError handlers in there use logging without first caring about whether or not