• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python threading.stack_size函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: run

    def run(self, arglist):
        threading.stack_size(65536)
        # Get the sequence variables

        args = self.parseArgsKeyValue(arglist)
        threads = int(args['threads'])
        iterations = int(args.get("interations", 1))

        # Get the list of VMs - this is everything that begins with "clone" (cloned in _TCCloneVMs)
        vms = [x for x in xenrt.TEC().registry.instanceGetAll() if x.name.startswith("clone")]

        self.doVMOperations(vms, threads, iterations)
开发者ID:johnmdilley,项目名称:xenrt,代码行数:12,代码来源:xdscalability.py


示例17: callWithLargeStack

def callWithLargeStack(f,*args):
    import sys
    import threading
    threading.stack_size(2**27)  # 64MB stack
    sys.setrecursionlimit(2**27) # will hit 64MB stack limit first
    # need new thread to get the redefined stack size
    def wrappedFn(resultWrapper): resultWrapper[0] = f(*args)
    resultWrapper = [None]
    #thread = threading.Thread(target=f, args=args)
    thread = threading.Thread(target=wrappedFn, args=[resultWrapper])
    thread.start()
    thread.join()
    return resultWrapper[0]
开发者ID:peterpod,项目名称:python_algorithms,代码行数:13,代码来源:floodFillPixel.py


示例18: checksingleprocess

def checksingleprocess(ipqueue,cacheResult,max_threads):
    threadlist = []
    threading.stack_size(96 * 1024)
    evt_finish = threading.Event()
    evt_ready = threading.Event()    
    qsize = ipqueue.qsize()
    maxthreads = qsize if qsize < max_threads else max_threads
    PRINT('need create max threads count: %d,total ip cnt: %d ' % (maxthreads, qsize))
    for i in xrange(1, maxthreads + 1):
        ping_thread = Ping(ipqueue,cacheResult,evt_finish,evt_ready)
        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()))
            "can not create new thread"
            break
        threadlist.append(ping_thread)
    evt_ready.wait()
    error = 0
    try:
        time_begin = time.time()
        logtime = time_begin
        count = Ping.getCount()
        lastcount = count
        while count > 0:
            evt_finish.wait(2)
            time_end = time.time()
            queuesize = ipqueue.qsize()
            count = Ping.getCount()
            if lastcount != count or queuesize > 0:
                time_begin = time_end
                lastcount = count
            else:
                if time_end - time_begin > g_handshaketimeout * 5:
                    dumpstacks()
                    error = 1
                    break
            if time_end - logtime > 60:
                PRINT("has thread count:%d,ip total cnt:%d" % (Ping.getCount(),queuesize))
                logtime = time_end
            count = Ping.getCount()
        evt_finish.set()
    except KeyboardInterrupt:
        PRINT("need wait all thread end...")
        evt_finish.set()
    if error == 0:
        for p in threadlist:
            p.join()
    cacheResult.close()
开发者ID:178220709,项目名称:PyHello,代码行数:50,代码来源:get_rand_ip.py


示例19: create_app

def create_app(flask_config_name=None, **kwargs):
    """
    Entry point to the Flask RESTful Server application.
    """
    # This is a workaround for Alpine Linux (musl libc) quirk:
    # https://github.com/docker-library/python/issues/211
    import threading
    threading.stack_size(2*1024*1024)

    app = Flask(__name__, **kwargs)

    env_flask_config_name = os.getenv('FLASK_CONFIG')
    if not env_flask_config_name and flask_config_name is None:
        flask_config_name = 'local'
    elif flask_config_name is None:
        flask_config_name = env_flask_config_name
    else:
        if env_flask_config_name:
            assert env_flask_config_name == flask_config_name, (
                "FLASK_CONFIG environment variable (\"%s\") and flask_config_name argument "
                "(\"%s\") are both set and are not the same." % (
                    env_flask_config_name,
                    flask_config_name
                )
            )

    try:
        app.config.from_object(CONFIG_NAME_MAPPER[flask_config_name])
    except ImportError:
        if flask_config_name == 'local':
            app.logger.error(
                "You have to have `local_config.py` or `local_config/__init__.py` in order to use "
                "the default 'local' Flask Config. Alternatively, you may set `FLASK_CONFIG` "
                "environment variable to one of the following options: development, production, "
                "testing."
            )
            sys.exit(1)
        raise

    if app.config['REVERSE_PROXY_SETUP']:
        app.wsgi_app = ProxyFix(app.wsgi_app)

    from . import extensions
    extensions.init_app(app)

    from . import modules
    modules.init_app(app)

    return app
开发者ID:sapphirus15,项目名称:flask-restplus-server-example,代码行数:49,代码来源:__init__.py


示例20: __init__

 def __init__(self, min_workers = 2, stack_size = 512):
     threading.stack_size(stack_size * 1024)
     self._logger = logging.getLogger('atp')
     self._tasks = queue.Queue()
     self._running_tasks = []
     self._min_workers = min_workers + 1 # for the monitoring thread
     self._workers = 0
     self._avail_workers = 0
     self._countlck = threading.Lock()
     self._task_added = threading.Event()
     self._killev = threading.Event()
     self._all_died = threading.Event()
     self.add_worker(self._min_workers)
     mt = Task(target=self.__volume_monitor, infinite=True)
     self.run(mt)
开发者ID:Zearin,项目名称:python-atp,代码行数:15,代码来源:concurrency.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python threading.BoundedSemaphore类代码示例发布时间:2022-05-27
下一篇:
Python threading.settrace函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap