JoinableQueue.join() 阻止了什么?
What does JoinableQueue.join() Block?
JoinableQueue
的文档说
join() Block until all items in the queue have been gotten and processed
我知道当我调用Process.join()
或Thread.join()
时,当前进程或线程的执行会停止,直到我调用join方法的进程或线程退出。
Process
的文档使用与 JoinableQueue
相同的语言
join([timeout]) Block the calling thread until the process whose join() method is called terminates or until the optional timeout occurs.
我总能理解 "block" 是指暂停调用线程直到满足某些条件吗?我在文档中找不到任何确认。如果我搜索 "block python",我只会找到有关代码块或我在上面引用的相同文档的信息。
Python 的文档在 http://en.wikipedia.org/wiki/Process_state 的经典意义上使用 "blocked"(以及相同词干 "block" 的其他形式)——任何线程(或process) 可以是 "running",或 "ready"(但等待 CPU),或 "blocked"(然后 "terminated" 一旦它基本上完成) .
(特别是在CPython中,在一个给定的进程内,无论如何只能有一个线程"running"Python代码许多 CPU 可用——抽象意义上的其他 "ready" 实际上在内部被全局解释器锁又名 GIL 阻止了——但是,这是一个实现细节,仅适用于某些实现,不要 Python 作为 语言 ).
JoinableQueue
的文档说
join() Block until all items in the queue have been gotten and processed
我知道当我调用Process.join()
或Thread.join()
时,当前进程或线程的执行会停止,直到我调用join方法的进程或线程退出。
Process
的文档使用与 JoinableQueue
join([timeout]) Block the calling thread until the process whose join() method is called terminates or until the optional timeout occurs.
我总能理解 "block" 是指暂停调用线程直到满足某些条件吗?我在文档中找不到任何确认。如果我搜索 "block python",我只会找到有关代码块或我在上面引用的相同文档的信息。
Python 的文档在 http://en.wikipedia.org/wiki/Process_state 的经典意义上使用 "blocked"(以及相同词干 "block" 的其他形式)——任何线程(或process) 可以是 "running",或 "ready"(但等待 CPU),或 "blocked"(然后 "terminated" 一旦它基本上完成) .
(特别是在CPython中,在一个给定的进程内,无论如何只能有一个线程"running"Python代码许多 CPU 可用——抽象意义上的其他 "ready" 实际上在内部被全局解释器锁又名 GIL 阻止了——但是,这是一个实现细节,仅适用于某些实现,不要 Python 作为 语言 ).