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

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

          <bdo id='c1HnR'></bdo><ul id='c1HnR'></ul>

        Windows 10 上的 Python 多处理

        时间:2023-08-06

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

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

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

                  <tbody id='xFNaL'></tbody>
                  <tfoot id='xFNaL'></tfoot>

                  本文介绍了Windows 10 上的 Python 多处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在 Windows 7 电脑和 Windows 10 笔记本电脑上运行一些代码:

                  I'm running some code on both a Windows 7 pc and a Windows 10 laptop:

                  def project(filename):
                      **Do Something Here**
                  
                  
                  if __name__ == '__main__':
                      pool = Pool(processes=4)
                      results = [pool.apply_async(project, args=(filename,)) for filename in filenamelist]
                      output = [p.get() for p in results]
                      print output
                  

                  两台计算机都是双核/4 线程,因此它们都应该可以很好地运行 4 个进程.我遇到的问题是,当我在 Windows 10 上运行代码时,我运行了 4 个 python 进程,但它们使用 0% 的 cpu,并且它们不会输出任何东西,这与 Windows 7 pc 不同,它将在所有 4线程和完美的工作.

                  Both computers are dual core/4 threads, so they should both be fine running 4 processes. The problem I have is that when I run the code on Windows 10 I get 4 python processes running, but they use 0% of the cpu and they will not output anything, unlike the Windows 7 pc which will run at full usage on all 4 threads and work perfectly.

                  如果我不使用多处理,代码在 Windows 10 笔记本电脑上运行良好,所以问题一定与此有关.使用 Python 进行多处理还不能在 Windows 10 中运行吗?顺便说一句,我在两台机器上都运行 Python 2.7.

                  The code works fine on the Windows 10 laptop if I don't use multiprocessing, so the problem must be related to that. Does multiprocessing with Python not work in Windows 10 yet? I am running Python 2.7 on both machines by the way.

                  :Windows 7 电脑处理器是 i5-650,Windows 10 笔记本电脑处理器是 i3-2370M

                  : Windows 7 pc processor is an i5-650, Windows 10 laptop processor is an i3-2370M

                  [更新]:我将笔记本电脑恢复到 Windows 8.1,并且运行完全相同的代码,这绝对是 Windows 10 的问题.

                  [Update]: I reverted the laptop back to Windows 8.1 and the exact same code runs as intended, this is definitely a Windows 10 issue.

                  :我用来生成 filenamelist 的方法如下,但是这在 Windows 7 上运行良好.

                  : The method I'm using to generate the filenamelist is as follows, however this works fine on Windows 7.

                  def get_unfinished_files(indir, outdir):
                      filenamelist = []
                      for filename in os.listdir(indir):
                          if filename not in os.listdir(outdir) and filename.endswith('.png'):
                              filenamelist.append(filename)
                      return filenamelist
                  

                  推荐答案

                  遇到了类似的问题.正如我发现的那样,在我的情况下,这只是 python 中的一个错误:https://bugs.python.org/issue35797

                  Had similar issue. As I found, it was just a bug in python in my case: https://bugs.python.org/issue35797

                  通过venv使用multiprocessing时发生.

                  Bugfix 在 Python 3.7.3 中发布.

                  Bugfix is released in Python 3.7.3.

                  这篇关于Windows 10 上的 Python 多处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:共享内存中用于多处理的大型 numpy 数组:这种方法 下一篇:使用 Python 将巨大的嵌套循环划分为 8 个(或更多

                  相关文章

                  最新文章

                1. <legend id='m9Frc'><style id='m9Frc'><dir id='m9Frc'><q id='m9Frc'></q></dir></style></legend>

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

                      <bdo id='m9Frc'></bdo><ul id='m9Frc'></ul>

                  1. <tfoot id='m9Frc'></tfoot>
                  2. <small id='m9Frc'></small><noframes id='m9Frc'>