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

    • <bdo id='68DC8'></bdo><ul id='68DC8'></ul>
    <tfoot id='68DC8'></tfoot>
    <legend id='68DC8'><style id='68DC8'><dir id='68DC8'><q id='68DC8'></q></dir></style></legend>

      <small id='68DC8'></small><noframes id='68DC8'>

      1. Python 2.6 通过队列/管道/等发送连接对象

        时间:2023-08-06
          <bdo id='k35lk'></bdo><ul id='k35lk'></ul>

        • <small id='k35lk'></small><noframes id='k35lk'>

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

                  本文介绍了Python 2.6 通过队列/管道/等发送连接对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  鉴于 此错误(Python 问题 4892) 会导致以下错误:

                  Given this bug (Python Issue 4892) that gives rise to the following error:

                  >>> import multiprocessing
                  >>> multiprocessing.allow_connection_pickling()
                  >>> q = multiprocessing.Queue()
                  >>> p = multiprocessing.Pipe()
                  >>> q.put(p)
                  >>> q.get()
                  Traceback (most recent call last):
                    File "<stdin>", line 1, in <module>
                    File     "/.../python2.6/multiprocessing/queues.py", line 91, in get
                      res = self._recv()
                  TypeError: Required argument 'handle' (pos 1) not found
                  

                  有人知道在队列上传递 Connection 对象的解决方法吗?

                  Does anyone know of a workaround to pass a Connection object on a Queue?

                  谢谢.

                  推荐答案

                  (我相信是)一个更好的方法,经过一些玩弄(我遇到了同样的问题.想通过管道穿过管道.)之前发现这篇文章:

                  (What I believe is) A better method, after some playing around (I was having the same problem. Wanted to pass a pipe through a pipe.) before discovering this post:

                  >>> from multiprocessing import Pipe, reduction
                  >>> i, o = Pipe()
                  >>> reduced = reduction.reduce_connection(i)
                  >>> newi = reduced[0](*reduced[1])
                  >>> newi.send("hi")
                  >>> o.recv()
                  'hi'
                  

                  我不完全确定为什么要以这种方式构建(有人需要深入了解多处理的减少部分到底是什么),但它确实有效,并且不需要导入泡菜.除此之外,它的功能与上述非常接近,但更简单.我还把它扔进了 python 错误报告,以便其他人知道解决方法.

                  I'm not entirely sure why this is built this way (someone would need insight into what the heck the reduction part of multiprocessing is about for that) but it does definitely work, and requires no pickle import. Other than that, it's pretty close to the above in what it does, but simpler. I also threw this into the python bug report so others know of the workaround.

                  这篇关于Python 2.6 通过队列/管道/等发送连接对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:multiprocessing.Queue 的管道损坏错误 下一篇:共享内存中用于多处理的大型 numpy 数组:这种方法

                  相关文章

                  最新文章

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

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

                    2. <tfoot id='QRucl'></tfoot>
                      • <bdo id='QRucl'></bdo><ul id='QRucl'></ul>