no multithreading?

Tim Peters tim_one at email.msn.com
Thu Jan 20 15:19:19 EST 2000


[Nemeth Miklos]
> This can only be implemented using real threads.

Python threads are real threads.

> If a Python thread is about to execute a long operation
> implemented in C (for example a database call), this
> thread will be blocked untill the called procedure returns.

The thread isn't blocked, it's off running the C code.  *Other* threads will
be blocked from executing Python code for the duration unless the author of
the C code did some macro magic to release Python's global interpreter lock
(which most C extension authors are pretty good about doing).

> What operating system threads are going to execute the
> other Python threads while this proc is running?

This is unanswerable because it assumes a false dichotomy <wink>.  Python's
threads build on whichever flavor of native platform threads it was compiled
to use; it's a config option at the time you build Python, and varies across
platform and (on platforms that support more than one thread package)
personal preference.

> By the way I bought Mark Lutz's Programming Python, and
> I am a bit disappointed that he does not even mention
> multi-threading in the 870-page book.

Threading still has a relatively small audience (e.g., check out the usual
(lack of!) traffic on Python's Thread-SIG).

> Is there another book that explains more advanced
> features of Python?

A list of current Python titles can be found at

    http://www.python.org/psa/bookstore/

Don't know whether any cover thread programming specifically.  threading.py
is the preferred Python thread API, and was modeled on Java's thread
gimmicks, so Java books are also relevant.

I think Python is a good language in which to learn threading, but so far I
don't know of any intro material written to such an audience.  Guido started
to write a thread tutorial a few years ago, but it's a large, intricate
topic and he didn't get much beyond the first "print" stmt <0.9 wink>.

threading-works-best-for-those-who-already-know-it-ly
    y'rs  - tim






More information about the Python-list mailing list