1. <legend id='dEmzZ'><style id='dEmzZ'><dir id='dEmzZ'><q id='dEmzZ'></q></dir></style></legend>
      <bdo id='dEmzZ'></bdo><ul id='dEmzZ'></ul>
    1. <small id='dEmzZ'></small><noframes id='dEmzZ'>

      <tfoot id='dEmzZ'></tfoot>
    2. <i id='dEmzZ'><tr id='dEmzZ'><dt id='dEmzZ'><q id='dEmzZ'><span id='dEmzZ'><b id='dEmzZ'><form id='dEmzZ'><ins id='dEmzZ'></ins><ul id='dEmzZ'></ul><sub id='dEmzZ'></sub></form><legend id='dEmzZ'></legend><bdo id='dEmzZ'><pre id='dEmzZ'><center id='dEmzZ'></center></pre></bdo></b><th id='dEmzZ'></th></span></q></dt></tr></i><div id='dEmzZ'><tfoot id='dEmzZ'></tfoot><dl id='dEmzZ'><fieldset id='dEmzZ'></fieldset></dl></div>
    3. 如何同时运行两个函数

      How to run two functions simultaneously(如何同时运行两个函数)

      <tfoot id='HcMJI'></tfoot>
      • <small id='HcMJI'></small><noframes id='HcMJI'>

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

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

              • 本文介绍了如何同时运行两个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在运行测试,但我想同时运行 2 个函数.我有一个摄像头,我告诉它通过 suds 移动,然后我通过 SSH 登录到摄像头以检查摄像头设置的速度.当我检查速度时,相机已经停止,所以没有速度可用.有没有办法让这些功能同时运行以测试相机的速度.示例代码如下:

                I am running test but I want to run 2 functions at the same time. I have a camera and I am telling it to move via suds, I am then logging into the camera via SSH to check the speed the camera is set to. When I check the speed the camera has stopped so no speed is available. Is there a way I can get these functions to run at the same time to test the speed of the camera. Sample code is below:

                class VerifyPan(TestAbsoluteMove):
                
                    def runTest(self):
                
                        self.dest.PanTilt._x=350
                
                        # Runs soap move command
                        threading.Thread(target = SudsMove).start()
                
                        self.command = './ptzpanposition -c 0 -u degx10'
                
                        # Logs into camera and checks speed
                        TestAbsoluteMove.Ssh(self)
                
                        # Position of the camera verified through Ssh (No decimal point added to the Ssh value)
                        self.assertEqual(self.Value, '3500')
                

                我现在已经尝试了下面提到的线程模块.线程不与函数 TestAbsoluteMove.Ssh() 同步运行.我还需要其他代码来完成这项工作吗?

                I have now tried the threading module as mentioned below. The thread does not run in sync with the function TestAbsoluteMove.Ssh(). Is there any other code I need to make this work.

                我已经研究了将参数放入线程语句中,以表明线程在 Ssh() 函数时运行.有谁知道在这个语句中输入什么?

                I have looked at putting arguments into the thread statement that state the thread runs when the Ssh() function. Does anyone know what to enter in this statement?

                对不起,如果我没有正确解释.SudsMove"功能移动相机,Ssh"功能登录相机并检查相机当前移动的速度.问题是当Ssh"功能登录相机时已经停止.我需要两个函数并行运行,这样我就可以在相机仍在移动时检查它的速度.

                Sorry if I haven't explained correctly. The 'SudsMove' function moves the camera and the 'Ssh' function logs into the camera and checks the speed the camera is currently moving at. The problem is that by the time the 'Ssh' function logs in the camera has stopped. I need both functions to run in parallel so I can check the camera speed while it is still moving.

                谢谢

                推荐答案

                如果你想使用通用的Python实现(CPython),你当然可以使用multiprocessing 模块,其中 创造奇迹(您可以将不可腌制的参数传递给子进程,杀死任务,...),提供类似于线程的接口,并且不遭受全局解释器锁定.

                If you want to use the common Python implementation (CPython), you can certainly use the multiprocessing module, which does wonders (you can pass non-pickleable arguments to subprocesses, kill tasks,…), offers an interface similar to that of threads, and does not suffer from the Global Interpreter Lock.

                缺点是会产生子进程,比创建线程需要更多时间;如果您有很多很多短期任务,这应该只是一个问题.此外,由于数据在进程之间传递(通过序列化),大数据既需要很长时间才能传递,最终会占用大量内存(因为它在每个进程之间重复).在每个任务花费较长"时间并且每个任务进出的数据不是太大的情况下,multiprocessing 模块应该很棒.

                The downside is that subprocesses are spawned, which takes more time than creating threads; this should only be a problem if you have many, many short tasks. Also, since data is passed (via serialization) between processes, large data both takes a long time to pass around and ends up having a large memory footprint (as it is duplicated between each process). In situations where each task takes a "long" time and the data in and out of each task is not too large, the multiprocessing module should be great.

                这篇关于如何同时运行两个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)

                      • <tfoot id='fNrDC'></tfoot>
                          <tbody id='fNrDC'></tbody>

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

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

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