1. <tfoot id='xTmgv'></tfoot>
      <bdo id='xTmgv'></bdo><ul id='xTmgv'></ul>

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

    3. <small id='xTmgv'></small><noframes id='xTmgv'>

    4. Python 队列 get()/task_done() 问题

      时间:2023-09-29
        <tfoot id='swgKg'></tfoot>

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

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

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

                <legend id='swgKg'><style id='swgKg'><dir id='swgKg'><q id='swgKg'></q></dir></style></legend>

              1. 本文介绍了Python 队列 get()/task_done() 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我的消费者端:

                m = queue.get()
                queue.task_done()
                
                <rest of the program>
                

                问题:

                1. task_done() 是否有效地将 m 从队列中弹出并释放消费者在队列中的所有锁?

                1. Does task_done() effectively pops m off the queue and release whatever locks the consumer has on the queue?

                我需要在程序的其余部分使用 m.它是否安全,或者我需要在调用 task_done() 之前复制它还是 mtask_done() 之后可用?

                I need to use m during the rest of the program. Is it safe, or do I need to copy it before I call task_done() or is m usable after task_done()?

                快乐

                推荐答案

                不,queue.get() 将项目从队列中弹出.在你这样做之后,你可以对它做任何你想做的事情,只要制作者按照它应该的方式工作并且不再触摸它.queue.task_done() 被调用只是为了通知队列你已经完成了某事(它甚至不知道具体的项目,它只是计算队列中未完成的项目),所以 queue.join() 知道工作已经完成.

                No, queue.get() pops the item off the queue. After you do that, you can do whatever you want with it, as long as the producer works like it should and doesn't touch it anymore. queue.task_done() is called only to notify the queue that you are done with something (it doesn't even know about the specific item, it just counts unfinished items in the queue), so that queue.join() knows the work is finished.

                这篇关于Python 队列 get()/task_done() 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:等效于带有工作“线程"的 asyncio.Queues 下一篇:将超时参数添加到 python 的 Queue.join()

                相关文章

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

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

                  1. <tfoot id='zLbew'></tfoot>

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

                    <legend id='zLbew'><style id='zLbew'><dir id='zLbew'><q id='zLbew'></q></dir></style></legend>