File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Wrapping/Generators/Python Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ def custom_callback(name, progress):
30
30
import sys
31
31
import os
32
32
33
+ # test setting the number of threads
34
+ itk .set_nthreads (4 )
35
+ assert itk .get_nthreads () == 4
36
+
33
37
# test the force load function
34
38
itk .force_load ()
35
39
Original file line number Diff line number Diff line change 27
27
# [K erases the end of the line
28
28
clrLine = "\033 [2000D\033 [K"
29
29
30
+ def set_nthreads (number_of_threads ):
31
+ """
32
+ Support convenient set of the number of threads.
33
+ Use example (in python):
34
+ import itk
35
+ itk.set_nthreads(4) ## use 4 threads
36
+ """
37
+ assert number_of_threads > 0 , "Please set a possitive number of threads instead of %d" % number_of_threads
38
+
39
+ import itk
40
+ threader = itk .MultiThreaderBase .New ()
41
+ threader .SetGlobalDefaultNumberOfThreads (number_of_threads )
42
+
43
+ def get_nthreads ():
44
+ """
45
+ Get the number of threads
46
+ """
47
+ import itk
48
+ threader = itk .MultiThreaderBase .New ()
49
+ return threader .GetGlobalDefaultNumberOfThreads ()
30
50
31
51
def auto_not_in_place (v = True ):
32
52
"""Force it to not run in place
You can’t perform that action at this time.
0 commit comments