问题描述
最近在队列设计中引入了延迟处理的能力以及实现FIFO"等.
Was recently introduced to the queue design in regards to ability to defer processing as well as implementing a "FIFO" etc.
查看文档以尝试获取示例队列以了解如何在我自己的设计/程序中实现它.但是我在运行这段代码时遇到了问题:
Looked through the documentation in attempt to get a sample queue going to understand how to implement it in my own design / program. But I'm having issues with just running this code:
问题:希望有人解释 for 循环在做什么,我在运行代码时遇到错误,所以我必须遗漏一些东西.
Question: Would like someone to explain what the for loops are doing, I get an error just running the code so I have to be missing something.
发生的问题错误:NameError:未定义全局名称num_worker_threads"
感谢-Python新手-
Thank you from a -Python Novice-
推荐答案
for循环正在启动一些工作线程来执行worker"定义的功能.这是应该在您的系统上以 python 2.7 运行的工作代码.
The for loop is launching a number of worker threads to perform the function defined by "worker". Here is working code that should run on your system in python 2.7.
每个@handle 的 Python 3 版本
Python 3 version per @handle
这篇关于学习python中的Queue模块(如何运行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!