[Twisted-Python] when will failure.Failure() be a problem?
glyph at twistedmatrix.com
Fri Mar 23 16:18:45 EDT 2012
On Mar 23, 2012, at 8:30 AM, Itamar Turner-Trauring wrote:
> On 03/23/2012 01:48 AM, gelin yan wrote:
>> Hi All
>> As regards issues like #5567 & #4219, Failure object creation is not
>> thread safe. I use deferToThread daily due to many blocking apis still
>> have to be used in my system. I looked into the code and noticed there
>> is a global count used in Failure.__init__. An increment will be made
>> for every __init__ invoke. I consider it is one part can be treated as
>> thread unsafe.
> Oh, and the pdb thing mentioned in 4219 only happens in debug mode,
> which won't be used in production (don't want pdb sessions in a live
Also, the PDB bug is only a problem because PDB itself isn't thread safe. Python has support for threads; the fact that its built-in debugger doesn't should be mildly embarrassing for those who maintain it :). But there are thread-safe debuggers out there that rely on more structured things than whatever stdio happens to be doing at the time; we should probably support some of those.
There's a list on <http://wiki.python.org/moin/PythonDebuggers> if anyone is interested in improving Twisted's debugging support...
More information about the Twisted-Python