本文整理匯總了Python中threading.stack_size方法的典型用法代碼示例。如果您正苦於以下問題:Python threading.stack_size方法的具體用法?Python threading.stack_size怎麽用?Python threading.stack_size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類threading
的用法示例。
在下文中一共展示了threading.stack_size方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import threading [as 別名]
# 或者: from threading import stack_size [as 別名]
def __init__(self, taskmaster, num, stack_size):
"""Create a new parallel job given a taskmaster.
The taskmaster's next_task() method should return the next
task that needs to be executed, or None if there are no more
tasks. The taskmaster's executed() method will be called
for each task when it is successfully executed, or failed()
will be called if the task failed to execute (i.e. execute()
raised an exception).
Note: calls to taskmaster are serialized, but calls to
execute() on distinct tasks are not serialized, because
that is the whole point of parallel jobs: they can execute
multiple tasks simultaneously. """
self.taskmaster = taskmaster
self.interrupted = InterruptState()
self.tp = ThreadPool(num, stack_size, self.interrupted)
self.maxjobs = num
示例2: __init__
# 需要導入模塊: import threading [as 別名]
# 或者: from threading import stack_size [as 別名]
def __init__(self, num, stack_size, interrupted):
"""Create the request and reply queues, and 'num' worker threads.
One must specify the stack size of the worker threads. The
stack size is specified in kilobytes.
"""
self.requestQueue = queue.Queue(0)
self.resultsQueue = queue.Queue(0)
try:
prev_size = threading.stack_size(stack_size*1024)
except AttributeError, e:
# Only print a warning if the stack size has been
# explicitly set.
if not explicit_stack_size is None:
msg = "Setting stack size is unsupported by this version of Python:\n " + \
e.args[0]
SCons.Warnings.warn(SCons.Warnings.StackSizeWarning, msg)
示例3: __init__
# 需要導入模塊: import threading [as 別名]
# 或者: from threading import stack_size [as 別名]
def __init__(self, taskmaster, num, stack_size):
"""Create a new parallel job given a taskmaster.
The taskmaster's next_task() method should return the next
task that needs to be executed, or None if there are no more
tasks. The taskmaster's executed() method will be called
for each task when it is successfully executed or failed()
will be called if the task failed to execute (i.e. execute()
raised an exception).
Note: calls to taskmaster are serialized, but calls to
execute() on distinct tasks are not serialized, because
that is the whole point of parallel jobs: they can execute
multiple tasks simultaneously. """
self.taskmaster = taskmaster
self.interrupted = InterruptState()
self.tp = ThreadPool(num, stack_size, self.interrupted)
self.maxjobs = num
示例4: test_various_ops_large_stack
# 需要導入模塊: import threading [as 別名]
# 或者: from threading import stack_size [as 別名]
def test_various_ops_large_stack(self):
if verbose:
print 'with 1MB thread stack size...'
try:
threading.stack_size(0x100000)
except thread.error:
if verbose:
print 'platform does not support changing thread stack size'
return
self.test_various_ops()
threading.stack_size(0)
# this test is not applicable to jython since
# 1. Lock is equiv to RLock, so this weird sync behavior won't be seen
# 2. We use a weak hash map to map these threads
# 3. This behavior doesn't make sense for Jython since any foreign
# Java threads can use the same underlying locks, etc
示例5: test_various_ops_small_stack
# 需要導入模塊: import threading [as 別名]
# 或者: from threading import stack_size [as 別名]
def test_various_ops_small_stack(self):
if verbose:
print 'with 256kB thread stack size...'
try:
threading.stack_size(262144)
except thread.error:
self.skipTest('platform does not support changing thread stack size')
self.test_various_ops()
threading.stack_size(0)
# run with a large thread stack size (1MB)
示例6: test_various_ops_large_stack
# 需要導入模塊: import threading [as 別名]
# 或者: from threading import stack_size [as 別名]
def test_various_ops_large_stack(self):
if verbose:
print 'with 1MB thread stack size...'
try:
threading.stack_size(0x100000)
except thread.error:
self.skipTest('platform does not support changing thread stack size')
self.test_various_ops()
threading.stack_size(0)
示例7: test_various_ops_small_stack
# 需要導入模塊: import threading [as 別名]
# 或者: from threading import stack_size [as 別名]
def test_various_ops_small_stack(self):
if verbose:
print 'with 256kB thread stack size...'
try:
threading.stack_size(262144)
except thread.error:
if verbose:
print 'platform does not support changing thread stack size'
return
self.test_various_ops()
threading.stack_size(0)
# run with a large thread stack size (1MB)
示例8: test_various_ops_large_stack
# 需要導入模塊: import threading [as 別名]
# 或者: from threading import stack_size [as 別名]
def test_various_ops_large_stack(self):
if verbose:
print 'with 1MB thread stack size...'
try:
threading.stack_size(0x100000)
except thread.error:
if verbose:
print 'platform does not support changing thread stack size'
return
self.test_various_ops()
threading.stack_size(0)
示例9: test_various_ops_small_stack
# 需要導入模塊: import threading [as 別名]
# 或者: from threading import stack_size [as 別名]
def test_various_ops_small_stack(self):
if verbose:
print('with 256kB thread stack size...')
try:
threading.stack_size(262144)
except _thread.error:
raise unittest.SkipTest(
'platform does not support changing thread stack size')
self.test_various_ops()
threading.stack_size(0)
# run with a large thread stack size (1MB)
示例10: test_various_ops_large_stack
# 需要導入模塊: import threading [as 別名]
# 或者: from threading import stack_size [as 別名]
def test_various_ops_large_stack(self):
if verbose:
print('with 1MB thread stack size...')
try:
threading.stack_size(0x100000)
except _thread.error:
raise unittest.SkipTest(
'platform does not support changing thread stack size')
self.test_various_ops()
threading.stack_size(0)
示例11: checksingleprocess
# 需要導入模塊: import threading [as 別名]
# 或者: from threading import stack_size [as 別名]
def checksingleprocess(ipqueue,cacheResult,max_threads):
threadlist = []
threading.stack_size(96 * 1024)
PRINT('need create max threads count: %d' % (max_threads))
for i in xrange(1, max_threads + 1):
ping_thread = Ping(ipqueue,cacheResult)
ping_thread.setDaemon(True)
try:
ping_thread.start()
except threading.ThreadError as e:
PRINT('start new thread except: %s,work thread cnt: %d' % (e, Ping.getCount()))
break
threadlist.append(ping_thread)
try:
quit = False
while not quit:
for p in threadlist:
if p.is_alive():
p.join(5)
elif Ping.getCount() == 0 or cacheResult.queryfinish():
quit = True
break
except KeyboardInterrupt:
PRINT("try to interrupt process")
ipqueue.queue.clear()
evt_ipramdomend.set()
cacheResult.close()