当前位置: 首页>>代码示例>>Python>>正文


Python threading.stack_size函数代码示例

本文整理汇总了Python中threading.stack_size函数的典型用法代码示例。如果您正苦于以下问题:Python stack_size函数的具体用法?Python stack_size怎么用?Python stack_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了stack_size函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, thread_num = 10):
        # 线程堆栈设置,防止占用大量内存
        stack_size(1024*1024)
        self.threadList = []

        self.threadNum = thread_num
        self.queue = Queue.Queue()
开发者ID:xzhoutxd,项目名称:jhs_v1,代码行数:7,代码来源:MyThread.py

示例2: start

    def start(self):
        

        # Verify that the user has a reasonable iDigi host set on their device.
        # Start by appending 1 to filename of pushed data
        self.__current_file_number = 1

        # Event to use for notification of meeting the sample threshold
        self.__threshold_event = threading.Event()

        # Count of samples since last data push
        self.__sample_count = 0
        
        #self.fc = f_counter()
        #
        #self.__core.set_service("fc", self.fc)

        # Here we grab the channel publisher
        channels = SettingsBase.get_setting(self, "channels")
        cm = self.__core.get_service("channel_manager")
        cp = cm.channel_publisher_get()

        # And subscribe to receive notification about new samples
    #    if len(channels) > 0:
    #        for channel in channels:
    #            cp.subscribe(channel, self.receive)
    #    else:
    #        cp.subscribe_to_all(self.receive)
        self.lock = threading.Lock()
        print threading.stack_size()
        threading.Thread.start(self)
        self.apply_settings()
        return True
开发者ID:Lewiswight,项目名称:MistAway-Gateway,代码行数:33,代码来源:MistAwayUploadJSON.py

示例3: main

def main():

    proxy = getcfg("http_proxy")
    if proxy:
        print "Using http proxy %s" % (proxy,)
        pollers.requestoptions["proxies"] = {"http": proxy, "https": proxy}

    try:
        threading.stack_size(512 * 1024)
    except BaseException as e:
        print "Error changing stack size:", repr(e)

    # Connect to the database...
    Database.get()

    parser = ParserThread()
    parser.start()

    for poller in POLLERS.values():
        poller.start()

    # wait for them to finish!
    for poller in POLLERS.values():
        while poller.is_alive():
            time.sleep(1)

    while parser.is_alive():
        time.sleep(1)

    return
开发者ID:EiNSTeiN-,项目名称:pbl,代码行数:30,代码来源:poll.py

示例4: checksingleprocess

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()
开发者ID:Andrew-dragon,项目名称:checkgoogleip,代码行数:27,代码来源:checkip.py

示例5: __init__

        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 as 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)
            except ValueError as e:
                msg = "Setting stack size failed:\n    " + str(e)
                SCons.Warnings.warn(SCons.Warnings.StackSizeWarning, msg)

            # Create worker threads
            self.workers = []
            for _ in range(num):
                worker = Worker(self.requestQueue, self.resultsQueue, interrupted)
                self.workers.append(worker)

            # Once we drop Python 1.5 we can change the following to:
            #if 'prev_size' in locals():
            if 'prev_size' in list(locals().keys()):
                threading.stack_size(prev_size)
开发者ID:blag,项目名称:keyczar,代码行数:32,代码来源:Job.py

示例6: __init__

    def __init__(self, num_threads=4, max_tasks=16, timeout=32,
                 init_local=None, stack_size=None):
        """
        Initialize and start a new thread pool.

        Exactly num_threads will be spawned. At most max_tasks
        can be queued before add() blocks; add() blocks for at
        most timeout seconds before raising an exception.

        You can pass a callable with one argument as init_local
        to initialize thread-local storage for each thread; see
        add() below for how to access thread-local storage from
        your tasks. For example:

            import sqlite3
            ...
            def init_local(local):
                local.connection = sqlite3.connect("some.db")
            ...
            pool = ThreadPool(init_local=init_local)
        """
        assert num_threads > 0
        assert max_tasks > 0
        assert timeout > 0
        # TODO: undocumented and probably a very bad idea
        assert stack_size is None or stack_size > 16*4096
        if stack_size is not None:
            T.stack_size(stack_size)
        self.__queue = Q.Queue(max_tasks)
        self.__timeout = timeout
        for _ in range(num_threads):
            _Worker(self.__queue, init_local)
开发者ID:madprof,项目名称:alpha-hub,代码行数:32,代码来源:pool.py

示例7: MakeTest

 def MakeTest(self, exp: Expression, caseNo: int):
     threading.stack_size(227680000)
     sys.setrecursionlimit(2147483647)
     test = Test()
     test.StartTest(caseNo, 1, 100, 'PEG', lambda w: self.TestPositive(exp, w), lambda w: self.TestNegative(exp, w))
     test.StartTest(caseNo, 101, 1000, 'PEG', lambda w: self.TestPositive(exp, w), lambda w: self.TestNegative(exp, w))
     test.StartTest(caseNo, 1001, 10000, 'PEG', lambda w: self.TestPositive(exp, w), lambda w: self.TestNegative(exp, w))
     test.StartTest(caseNo, 10001, 100000, 'PEG', lambda w: self.TestPositive(exp, w), lambda w: self.TestNegative(exp, w))        
开发者ID:wieczorekw,项目名称:wieczorekw.github.io,代码行数:8,代码来源:test_PEG.py

示例8: test_various_ops_small_stack

 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)
开发者ID:0xBADCA7,项目名称:grumpy,代码行数:9,代码来源:test_threading.py

示例9: test_various_ops_large_stack

 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)
开发者ID:0xBADCA7,项目名称:grumpy,代码行数:9,代码来源:test_threading.py

示例10: main

def main():
	try:
		print "Start listening..."
		threading.stack_size(1024 * 512)
		server = ThreadingTCPServer(('', 5060), ProxyServer)
		server_thread = threading.Thread(target=server.serve_forever)
		server_thread.start()
	except Exception, msg:
		print "Exception in main: ", msg
开发者ID:davidaq,项目名称:psProxy,代码行数:9,代码来源:socks5server.py

示例11: main

def main():
 #   MiB = 2 ** 20
 #   threading.stack_size(256 * MiB -1)
 #   sys.setrecursionlimit(10 ** 7)
 #   t = threading.Thread(target = main)
    maxvertexes=67108864
    threading.stack_size(maxvertexes)
    sys.setrecursionlimit(maxvertexes)
    thread = threading.Thread(target=main)
    thread.start()
开发者ID:nightrose79,项目名称:ProgrammingAssignment2,代码行数:10,代码来源:SCC_kosaraju_p.py

示例12: test_various_ops_large_stack

 def test_various_ops_large_stack(self):
     if verbose:
         print('with 1 MiB 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)
开发者ID:FFMG,项目名称:myoddweb.piger,代码行数:10,代码来源:test_threading.py

示例13: main

def main():
	try:
		print "Start listening..."
		threading.stack_size(1024 * 512 * 2)
		socket.setdefaulttimeout(30)
		server = ThreadingTCPServer(('', 5070), Socks5Client)
		server_thread = threading.Thread(target=server.serve_forever)
		server_thread.start()
	except Exception, msg:
		print "Exception in main: ", msg
开发者ID:davidaq,项目名称:psProxy,代码行数:10,代码来源:socks5client.py

示例14: scc_recursive

def scc_recursive():
    import sys, threading

    sys.setrecursionlimit(3000000)
    threading.stack_size(64 * 1024 * 1024)  # set thread stack 64M
    start = clock()
    thread = threading.Thread(target=SCC("SCC.txt", nodeNum=875714).scc_by_recursive)
    thread.start()
    thread.join()
    end = clock()
    print "run by recursion:", str(end - start)
开发者ID:zoyanhui,项目名称:Coursera-Learning,代码行数:11,代码来源:SCC.py

示例15: test_various_ops_large_stack

 def test_various_ops_large_stack(self):
     if verbose:
         six.print_('with 1MB thread stack size...')
     try:
         threading.stack_size(0x100000)
     except thread.error:
         if verbose:
             six.print_('platform does not support changing thread stack size')
         return
     self.test_various_ops()
     threading.stack_size(0)
开发者ID:dustyneuron,项目名称:gevent,代码行数:11,代码来源:test_threading_2.py


注:本文中的threading.stack_size函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。