basic python threading question

David Bolen db3l at fitlinxx.com
Fri Sep 29 18:45:20 EDT 2000


aahz at panix.com (Aahz Maruch) writes:

> > (me)
> >From a C extension perspective, your C code is only called from within
> >a single Python interpreter thread at a time (and is governed by the
> >global interpreter lock), so while your C code runs on behalf of a
> >Python request, there's only one native thread running against that
> >interpreter. (...)
> 
> I think what you really meant to say was that calls into extensions are
> serialized, because only one Python thread runs until the extension
> releases the GIL.  But as soon as the extension releases the GIL,
> another Python thread can call into the extension.

Yes, I meant to indicate (which my "governed by" phrase probably
didn't cover well) that at any point in time only a single native
thread - the one with the GIL - is executing on behalf of the Python
interpreter (unless you ignore the GIL which is a no-no).

I'm not sure I'd call this serializing the calls into the extension,
but rather serializing execution within the extension.  As you point
out you may have multiple calls live within an extension, but only one
actively interacting with the Python core, so the calls themselves
aren't serialized.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list