summarylogtreecommitdiffstats
path: root/memoryfix.patch
blob: 9680f63e3760800770788b1631246a3aa712dfff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
-- pycam-0.5.1.orig/src/pycam/Utils/threading.py 2011-06-10 10:54:51.000000000 -0400
+++ pycam-0.5.1/src/pycam/Utils/threading.py 2011-11-13 15:50:34.294437639 -0500
@@ -639,18 +639,21 @@
     if __multiprocessing and not disable_multiprocessing:
         # use the number of CPUs as the default number of worker threads
         pool = __multiprocessing.Pool(__num_of_processes)
-        if unordered:
-            imap_func = pool.imap_unordered
-        else:
-            imap_func = pool.imap
-        # Beware: we may not return "pool.imap" or "pool.imap_unordered"
-        # directly. It would somehow loose the focus and just hang infinitely.
-        # Thus we wrap our own generator around it.
-        for result in imap_func(func, args):
-            if callback and callback():
-                # cancel requested
-                break
-            yield result
+        try:
+            if unordered:
+                imap_func = pool.imap_unordered
+            else:
+                imap_func = pool.imap
+            # Beware: we may not return "pool.imap" or "pool.imap_unordered"
+            # directly. It would somehow loose the focus and just hang infinitely.
+            # Thus we wrap our own generator around it.
+            for result in imap_func(func, args):
+                if callback and callback():
+                    # cancel requested
+                    break
+                yield result
+        finally:
+            pool.terminate()
     else:
         for arg in args:
             if callback and callback():