Re: learning about threads and processes (was Re: what would you like to see in a 2nd edition Nutshell?)

2004-12-29 Thread Arthhur
On Wed, 29 Dec 2004 16:41:23 +0100, Alex Martelli wrote:
> 
> Hmmm, well, the concepts are reasonably independent of the programming
> language involved.  If anything, threads and processes may be more tied
> to whatever _operating system_ you're using.  A very fundamental but
> good introduction to processes (and other such basics) is for example at
> , but it
> will be only partially applicable if you need to understand in depth the
> process-model of Windows.  But of course this is about the concepts, not
> the practice of programming to interact with them.

Too basic. Doesn't speak to the "intermediate".  

I'll have you know, sir, you are speaking to someone who is
quite intermediate, at least in mediocre way.  Hummph ;)


>> If I want to no more than be able to follow, say, the current Idle code
>> of the PyShell module, I can find very little guidance from within the
>> canon of Python literature.
>> 
>> Help?
> 
> Hmmm - have you looked at Deitel, Deitel, Liperi, Wiedermann, "Python
> how to program", chapters 18 (Process Management) and 19
> (Multithreading), pages 613-687?  They seem to do a rather workmanlike
> job -- of course, they can't do full justice to the subjects in 75
> pages; and if you don't want to buy a vast, costly 1300-pages tome for
> the sake of those 75 pages, I can't really blame you, either.  Still,
> without some clarification of how (if at all) those 75 pages fail to
> meet your learning needs, it's hard to know what else to suggest.  And
> what about Norman Matloff's
> , the first
> google hit if you're looking for
> python threads

I never gotten to page 613 of any book in my life ;)

But the Matloff piece you site is in fact helpful to the intermediate.  

Frankly not sure how I missed it in past searches.  "Python threading" as
a google buries it a bit, but not that deeply.

This also comes up on a fresh search, and is to the point and at the level
of interest. It is also recent:

http://linuxgazette.net/107/pai.html


> ?  I haven't looked into it, but, again, without some specific
> explanation of how it fails to meet your needs, it's hard to offer
> alternatives.

The problem is when one starts off explaining threads by reference to
processes, I already have a practical problem.  Which, under what
circumstances.

Again referring back to the Idle code, class ModifiedInterpreter in the
PyShell module:

Within the space of a simple class, we are spawning 
a subprocess via:

self.rpcpid = os.spawnv(os.P_NOWAIT, sys.executable, args)

and a rpc client listening to a socket via:

self.rpcclt = MyRPCClient(addr)

which can be interrupted via a thread ala:

threading.Thread(target=self.__request_interrupt).start()

And then it gets a little complicated, to an intermediate ;)

Guess I am hoping to get to understand it as architecture, as well as as
code.

This happens to be another piece of code I am trying to digest, which
allows one to experiment with building PyGTK widgets from an interactive
prompt:

http://www.pygtk.org/pygtktutorial/examples/pygtkconsole.py

which uses os.fork and signals in its architecture, but no threads, as
opposed to this CookBook recipe:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109

which accomplishes a very similar functionality using threads as a
fundamental part of its strategy.

The closest thing I can think of as the kind of book I would love to see
is one similar to Steve Holden's book on web programming, which explained
lower level internet proctocols at the same time as it explained their
Python implementation.

Wonder what Steve's are doing this week? ;) 

Art
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learning about threads and processes (was Re: what would you like to see in a 2nd edition Nutshell?)

2004-12-29 Thread Aahz
In article <[EMAIL PROTECTED]>,
Alex Martelli <[EMAIL PROTECTED]> wrote:
>
>Hmmm - have you looked at Deitel, Deitel, Liperi, Wiedermann, "Python
>how to program", chapters 18 (Process Management) and 19
>(Multithreading), pages 613-687?  They seem to do a rather workmanlike
>job -- of course, they can't do full justice to the subjects in 75
>pages; and if you don't want to buy a vast, costly 1300-pages tome for
>the sake of those 75 pages, I can't really blame you, either.  

Except that it's a really, really piss-poor book.  That's an opinion
which I believe you've agreed with previously.

>And what about Norman Matloff's
>, the first
>google hit if you're looking for
>python threads
>?  I haven't looked into it, but, again, without some specific
>explanation of how it fails to meet your needs, it's hard to offer
>alternatives.

That's actually pretty good.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"19. A language that doesn't affect the way you think about programming,
is not worth knowing."  --Alan Perlis
-- 
http://mail.python.org/mailman/listinfo/python-list


learning about threads and processes (was Re: what would you like to see in a 2nd edition Nutshell?)

2004-12-29 Thread Alex Martelli
Arthur <[EMAIL PROTECTED]> wrote:
   ...
> speaking in Python. As to these concepts, the implicit point of view
> seems to be to leave Python to learn the concepts, and return to
> Python to understand its implementation of the details, once the
> concepts are well grasped.

Hmmm, well, the concepts are reasonably independent of the programming
language involved.  If anything, threads and processes may be more tied
to whatever _operating system_ you're using.  A very fundamental but
good introduction to processes (and other such basics) is for example at
, but it
will be only partially applicable if you need to understand in depth the
process-model of Windows.  But of course this is about the concepts, not
the practice of programming to interact with them.


> If I want to no more than be able to follow, say, the current Idle
> code of the PyShell module, I can find very little guidance from
> within the canon of Python literature.
> 
> Help?

Hmmm - have you looked at Deitel, Deitel, Liperi, Wiedermann, "Python
how to program", chapters 18 (Process Management) and 19
(Multithreading), pages 613-687?  They seem to do a rather workmanlike
job -- of course, they can't do full justice to the subjects in 75
pages; and if you don't want to buy a vast, costly 1300-pages tome for
the sake of those 75 pages, I can't really blame you, either.  Still,
without some clarification of how (if at all) those 75 pages fail to
meet your learning needs, it's hard to know what else to suggest.  And
what about Norman Matloff's
, the first
google hit if you're looking for
python threads
?  I haven't looked into it, but, again, without some specific
explanation of how it fails to meet your needs, it's hard to offer
alternatives.

It is, of course, out of the question that the Nutshell can get into the
tutorial business -- MY space budget for the whole "Threads and
processes" chapter is around 20 small pages, and I personally consider
it quite a feat to have managed to fit within that compass 4 pages of
advice on threaded program architecture as well as a down-to-the-bone
reference to modules threading, Queue, os (process-related subset) _and_
mmap;-).  Still, others _are_ writing Python tutorials, and it does seem
that books such as "Learning Python" and even "Dive into Python" are
(understandably, I guess) avoiding the subject... so, pinpointing what's
being looked for by learners, which Deitel et al, Matloff, etc, are
missing, might help future editions and versions of such books...


Alex
-- 
http://mail.python.org/mailman/listinfo/python-list