@@ -102,11 +102,13 @@ class _QThreadWorker(QtCore.QThread):
102
102
For use by the QThreadExecutor
103
103
"""
104
104
105
- def __init__ (self , queue , num ):
105
+ def __init__ (self , queue , num , stackSize = None ):
106
106
self .__queue = queue
107
107
self .__stop = False
108
108
self .__num = num
109
109
super ().__init__ ()
110
+ if stackSize is not None :
111
+ self .setStackSize (stackSize )
110
112
111
113
def run (self ):
112
114
queue = self .__queue
@@ -156,12 +158,20 @@ class QThreadExecutor:
156
158
... assert r == 4
157
159
"""
158
160
159
- def __init__ (self , max_workers = 10 ):
161
+ def __init__ (self , max_workers = 10 , stack_size = None ):
160
162
super ().__init__ ()
161
163
self .__max_workers = max_workers
162
164
self .__queue = Queue ()
165
+ if stack_size is None :
166
+ # Match cpython/Python/thread_pthread.h
167
+ if sys .platform .startswith ("darwin" ):
168
+ stack_size = 16 * 2 ** 20
169
+ elif sys .platform .startswith ("freebsd" ):
170
+ stack_size = 4 * 2 ** 20
171
+ elif sys .platform .startswith ("aix" ):
172
+ stack_size = 2 * 2 ** 20
163
173
self .__workers = [
164
- _QThreadWorker (self .__queue , i + 1 ) for i in range (max_workers )
174
+ _QThreadWorker (self .__queue , i + 1 , stack_size ) for i in range (max_workers )
165
175
]
166
176
self .__been_shutdown = False
167
177
0 commit comments