<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://wiki.riguz.com/index.php?action=history&amp;feed=atom&amp;title=Python%3AQueue</id>
	<title>Python:Queue - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.riguz.com/index.php?action=history&amp;feed=atom&amp;title=Python%3AQueue"/>
	<link rel="alternate" type="text/html" href="https://wiki.riguz.com/index.php?title=Python:Queue&amp;action=history"/>
	<updated>2026-06-02T22:00:38Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://wiki.riguz.com/index.php?title=Python:Queue&amp;diff=1839&amp;oldid=prev</id>
		<title>imported&gt;Soleverlee：​以“&lt;source lang=&quot;python&quot;&gt; def worker():     while True:         item = q.get()         if item is None:             break         do_work(item)         q.task_done()  q...”为内容创建页面</title>
		<link rel="alternate" type="text/html" href="https://wiki.riguz.com/index.php?title=Python:Queue&amp;diff=1839&amp;oldid=prev"/>
		<updated>2016-12-14T02:40:16Z</updated>

		<summary type="html">&lt;p&gt;以“&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt; def worker():     while True:         item = q.get()         if item is None:             break         do_work(item)         q.task_done()  q...”为内容创建页面&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
def worker():&lt;br /&gt;
    while True:&lt;br /&gt;
        item = q.get()&lt;br /&gt;
        if item is None:&lt;br /&gt;
            break&lt;br /&gt;
        do_work(item)&lt;br /&gt;
        q.task_done()&lt;br /&gt;
&lt;br /&gt;
q = queue.Queue()&lt;br /&gt;
threads = []&lt;br /&gt;
for i in range(num_worker_threads):&lt;br /&gt;
    t = threading.Thread(target=worker)&lt;br /&gt;
    t.start()&lt;br /&gt;
    threads.append(t)&lt;br /&gt;
&lt;br /&gt;
for item in source():&lt;br /&gt;
    q.put(item)&lt;br /&gt;
&lt;br /&gt;
# block until all tasks are done&lt;br /&gt;
q.join()&lt;br /&gt;
&lt;br /&gt;
# stop workers&lt;br /&gt;
for i in range(num_worker_threads):&lt;br /&gt;
    q.put(None)&lt;br /&gt;
for t in threads:&lt;br /&gt;
    t.join()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The origin post could be found [https://docs.python.org/3/library/queue.html here]&lt;br /&gt;
[[Category:Programe]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Soleverlee</name></author>
	</entry>
</feed>