• <tfoot id='MLnJs'></tfoot>

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

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

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

        如何在 Python 进程之间共享数据?

        时间:2023-05-27
        <legend id='93W3e'><style id='93W3e'><dir id='93W3e'><q id='93W3e'></q></dir></style></legend>

          <small id='93W3e'></small><noframes id='93W3e'>

          <tfoot id='93W3e'></tfoot>

                <tbody id='93W3e'></tbody>
                <bdo id='93W3e'></bdo><ul id='93W3e'></ul>

                1. <i id='93W3e'><tr id='93W3e'><dt id='93W3e'><q id='93W3e'><span id='93W3e'><b id='93W3e'><form id='93W3e'><ins id='93W3e'></ins><ul id='93W3e'></ul><sub id='93W3e'></sub></form><legend id='93W3e'></legend><bdo id='93W3e'><pre id='93W3e'><center id='93W3e'></center></pre></bdo></b><th id='93W3e'></th></span></q></dt></tr></i><div id='93W3e'><tfoot id='93W3e'></tfoot><dl id='93W3e'><fieldset id='93W3e'></fieldset></dl></div>
                  本文介绍了如何在 Python 进程之间共享数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在使用多处理为我的 Python 应用程序创建一个子进程.我想在我的父进程和子进程之间共享数据.需要说明的是,我需要异步共享这个,也就是说子进程和父进程会在代码运行期间更新数据.

                  I'm using multiprocessing to create a sub-process to my Python app. I would like to share data between my parent process and the child process. it's important to mention that I need to share this asynchronously, means that the child process and the parent process will update the data during the code running.

                  最好的方法是什么?

                  推荐答案

                  这是python文档中的一个简单示例 -

                  This is one simple example from python documentation -

                  from multiprocessing import Process, Queue
                  
                  def f(q):
                      q.put([42, None, 'hello'])
                  
                  if __name__ == '__main__':
                      q = Queue()
                      p = Process(target=f, args=(q,))
                      p.start()
                      print q.get()    # prints "[42, None, 'hello']"
                      p.join()
                  

                  你也可以使用管道,有关详细信息,请参阅 - https://docs.python.org/2/library/multiprocessing.html

                  You can use pipe as well, Refer for more details - https://docs.python.org/2/library/multiprocessing.html

                  这篇关于如何在 Python 进程之间共享数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:具有多处理功能的 Python 装饰器失败 下一篇:Python 在并行进程之间共享字典

                  相关文章

                  最新文章

                  1. <small id='8ALaf'></small><noframes id='8ALaf'>

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