• <legend id='hKhbL'><style id='hKhbL'><dir id='hKhbL'><q id='hKhbL'></q></dir></style></legend>
      <bdo id='hKhbL'></bdo><ul id='hKhbL'></ul>
    <i id='hKhbL'><tr id='hKhbL'><dt id='hKhbL'><q id='hKhbL'><span id='hKhbL'><b id='hKhbL'><form id='hKhbL'><ins id='hKhbL'></ins><ul id='hKhbL'></ul><sub id='hKhbL'></sub></form><legend id='hKhbL'></legend><bdo id='hKhbL'><pre id='hKhbL'><center id='hKhbL'></center></pre></bdo></b><th id='hKhbL'></th></span></q></dt></tr></i><div id='hKhbL'><tfoot id='hKhbL'></tfoot><dl id='hKhbL'><fieldset id='hKhbL'></fieldset></dl></div>

    1. <small id='hKhbL'></small><noframes id='hKhbL'>

    2. <tfoot id='hKhbL'></tfoot>

        在 python 脚本中设置堆栈大小

        时间:2023-09-27
        <tfoot id='ooHLA'></tfoot>

        <small id='ooHLA'></small><noframes id='ooHLA'>

          <bdo id='ooHLA'></bdo><ul id='ooHLA'></ul>
          <legend id='ooHLA'><style id='ooHLA'><dir id='ooHLA'><q id='ooHLA'></q></dir></style></legend>

              <tbody id='ooHLA'></tbody>

            <i id='ooHLA'><tr id='ooHLA'><dt id='ooHLA'><q id='ooHLA'><span id='ooHLA'><b id='ooHLA'><form id='ooHLA'><ins id='ooHLA'></ins><ul id='ooHLA'></ul><sub id='ooHLA'></sub></form><legend id='ooHLA'></legend><bdo id='ooHLA'><pre id='ooHLA'><center id='ooHLA'></center></pre></bdo></b><th id='ooHLA'></th></span></q></dt></tr></i><div id='ooHLA'><tfoot id='ooHLA'></tfoot><dl id='ooHLA'><fieldset id='ooHLA'></fieldset></dl></div>

                • 本文介绍了在 python 脚本中设置堆栈大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在将 csh 脚本转换为 python 脚本.该脚本调用了一个需要非常大堆栈的内存密集型可执行文件,因此 csh 脚本将堆栈大小设置为无限制:

                  I am converting a csh script to a python script. The script calls a memory-intensive executable which requires a very large stack, so the csh script sets the stacksize to unlimited:

                  limit stacksize unlimited
                  

                  当我尝试在 python 中重现这个脚本时,我以一种非常幼稚的方式执行它们,使用 os.system,例如:

                  When I try to reproduce this script in python, I execute them in a very naive manner, using os.system, e.g.:

                  os.system('some_executable')
                  

                  但我不知道如何告诉操作系统以无限堆栈大小运行这些可执行文件.有没有办法为 python 脚本中的调用指定堆栈大小?我应该使用一些低级系统调用吗?是否有一个模块(类似于shutil)来控制它?

                  But I do not know how to tell the OS to run these executables with unlimited stacksize. Is there a way to specify stacksize for calls within a python script? Is there some low-level system call that I should be using? And is there a module (similar to shutil) which controls this?

                  推荐答案

                  如果需要,您可以使用 shell 的 (u)limit 命令:

                  You can just use the (u)limit command of your shell, if you want:

                  os.system('ulimit -s unlimited; some_executable')
                  

                  或者(可能更好)使用 resource.setrlimit:

                  Or (probably better) use resource.setrlimit:

                  resource.setrlimit(resource.RLIMIT_STACK, (resource.RLIM_INFINITY, resource.RLIM_INFINITY))
                  

                  这篇关于在 python 脚本中设置堆栈大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Python 是否优化尾递归? 下一篇:如何在 pandas 中拆散(或旋转?)

                  相关文章

                  <legend id='MW3X6'><style id='MW3X6'><dir id='MW3X6'><q id='MW3X6'></q></dir></style></legend>

                    <small id='MW3X6'></small><noframes id='MW3X6'>

                  1. <i id='MW3X6'><tr id='MW3X6'><dt id='MW3X6'><q id='MW3X6'><span id='MW3X6'><b id='MW3X6'><form id='MW3X6'><ins id='MW3X6'></ins><ul id='MW3X6'></ul><sub id='MW3X6'></sub></form><legend id='MW3X6'></legend><bdo id='MW3X6'><pre id='MW3X6'><center id='MW3X6'></center></pre></bdo></b><th id='MW3X6'></th></span></q></dt></tr></i><div id='MW3X6'><tfoot id='MW3X6'></tfoot><dl id='MW3X6'><fieldset id='MW3X6'></fieldset></dl></div>
                      <bdo id='MW3X6'></bdo><ul id='MW3X6'></ul>
                  2. <tfoot id='MW3X6'></tfoot>