This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients amaury.forgeotdarc, anacrolix, docs@python, ncoghlan, nikratio, swapnil, verigak
Date 2010-09-21.13:03:19
SpamBayes Score 7.824852e-13
Marked as misclassified No
Message-id <AANLkTinUvBcUhxZmy8L_HCWhogM3b3jDG87Fcp4NWWwW@mail.gmail.com>
In-reply-to <1285043943.16.0.816529286647.issue6627@psf.upfronthosting.co.za>
Content
On Tue, Sep 21, 2010 at 2:39 PM, Swapnil Talekar <report@bugs.python.org> wrote:
> Swapnil Talekar <swapnil.st@gmail.com> added the comment:
> Nick, the last statement,
> "While this is correct for most purposes, it does mean that..."
> can be simplified to,
> "It means...".
> I had to read it several times before I realized, there is no "not" after "does" :)

The shorter version doesn't mean the same thing though - the ctypes
arrangement *really is* correct for most purposes. The only issue is
that threading.local won't persist, since the storage is blown away as
soon as the callback returns.

> BTW, since this particular arrangement of having a temporary thread state during the callback is particularly useful for ctypes (I cannot imagine any other usecase) and also it sort-of breaks things, a potential feature request could be to have consistent thread state during the lifetime of a C thread. I don't have much idea how to do that or whether it is even possible? Would anyone like to give a thought?

There's no easy way to make the thread state persist between calls, as
ctypes needs to destroy the thread state it creates at some point to
avoid a memory leak. Since it has no way of knowing when the
underlying C thread is no longer in use, it is forced to assume that
every call is going to be the last one from that thread and kill the
thread state.
History
Date User Action Args
2010-09-21 13:03:24ncoghlansetrecipients: + ncoghlan, amaury.forgeotdarc, nikratio, verigak, swapnil, anacrolix, docs@python
2010-09-21 13:03:21ncoghlanlinkissue6627 messages
2010-09-21 13:03:20ncoghlancreate