本文整理汇总了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()