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

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

      • <bdo id='wzFcO'></bdo><ul id='wzFcO'></ul>

      1. Python多处理 - 进程完成后如何释放内存?

        时间:2023-05-27

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

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

                  本文介绍了Python多处理 - 进程完成后如何释放内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我在使用 python 多处理库时遇到了一个奇怪的问题.

                  I encountered a weird problem while using python multiprocessing library.

                  我的代码如下所示:我为每个符号、日期"元组生成一个进程.之后我结合结果.

                  My code is sketched below: I spawn a process for each "symbol, date" tuple. I combine the results afterwards.

                  我希望当一个进程完成对符号,日期"元组的计算时,它应该释放它的内存吗?显然情况并非如此.我看到几十个进程(尽管我将进程池的大小设置为 7)在机器中挂起¹.它们不消耗 CPU,也不释放内存.

                  I expect that when a process has done computing for a "symbol, date" tuple, it should release its memory? apparently that's not the case. I see dozens of processes (though I set the process pool to have size 7) that are suspended¹ in the machine. They consume no CPU, and they don't release the memory.

                  如何让进程在完成计算后释放其内存?

                  How do I let a process release its memory, after it has done its computation?

                  谢谢!

                  ¹暂停"是指它们在 ps 命令中的状态显示为S+"

                  ¹ by "suspended" I mean their status in ps command is shown as "S+"

                  def do_one_symbol( symbol, all_date_strings ):
                      pool = Pool(processes=7)
                      results = [];
                      for date in all_date_strings:
                          res = pool.apply_async(work, [symbol, date])
                          results.append(res);
                  
                      gg = mm = ss = 0;
                      for res in results:
                          g, m, s = res.get()
                          gg += g; 
                          mm += m; 
                          ss += s;
                  

                  推荐答案

                  您是否尝试使用 pool.close 然后等待进程完成 pool.join,因为如果父进程继续运行并且不等待子进程他们会变成僵尸

                  这篇关于Python多处理 - 进程完成后如何释放内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:有没有办法将'stdin'作为参数传递给python中 下一篇:在 Python 中的进程之间共享许多队列

                  相关文章

                  最新文章

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

                      <legend id='dJ9FP'><style id='dJ9FP'><dir id='dJ9FP'><q id='dJ9FP'></q></dir></style></legend>
                    1. <small id='dJ9FP'></small><noframes id='dJ9FP'>