2

The documentation for JoinableQueue says

join() Block until all items in the queue have been gotten and processed

I know that when I call Process.join() or Thread.join(), the execution of the current process or thread is stopped until the process or thread who's join method I called exits.

The documentation for Process uses the same language as that for JoinableQueue

join([timeout]) Block the calling thread until the process whose join() method is called terminates or until the optional timeout occurs.

Can I always understand "block" to refer to pausing the calling thread until some condition has been met? I can't find any confirmation in the documentation. If I search for "block python", I only find information about blocks of code or the same documentation I quote above.

Cecilia
  • 4,512
  • 3
  • 32
  • 75
  • 1
    *Can I always understand "block" to refer to pausing the calling thread until some condition has been met?* In the context of multi-threading/multi-processing in python, almost always: yes. – jedwards Mar 27 '15 at 21:22
  • @jedwards Great! And `JoinableQueue` falls into multi-threading/multi-processing in python, I assume. – Cecilia Mar 27 '15 at 21:25
  • Indeed it does -- look at [its package](https://docs.python.org/2/library/multiprocessing.html) :) – jedwards Mar 27 '15 at 21:26
  • 1
    See [here](http://stackoverflow.com/questions/2407589/what-does-the-term-blocking-mean-in-programming) for a more generic question about the meaning of blocking. It's a term used across all of software development, not just in Python. – dano Mar 27 '15 at 21:33
  • @dano that's a good link, I didn't mean to suggest that blocking was only used in python, just that within that context, OP would be safe to associate that meaning with the term. I can't speak about how other languages decide to use it, if they decide to use it differently (which of course would be weird and confusing) -- but this was the reason for my qualification. Sorry if it was misleading. – jedwards Mar 27 '15 at 21:39

1 Answers1

4

Python's docs are using "blocked" (and other forms of the same stem "block") in the classical sense of http://en.wikipedia.org/wiki/Process_state -- any thread (or process) can be "running", or "ready" (but waiting for a CPU), or "blocked" (and then "terminated" once it is, essentially, finished).

(In CPython in particular, within a given process, only one thread can be "running" Python code no matter how many CPUs are available -- others which are in the abstract sense "ready" are in fact internally blocked by the Global Interpreter Lock aka GIL -- but, that's an implementation detail and only applies to certain implementations, not to Python as a language).

Alex Martelli
  • 854,459
  • 170
  • 1,222
  • 1,395