[Twisted-Python] exceptions in adbapi

Dave Peticolas dave at krondo.com
Mon Jul 11 19:45:58 MDT 2005


On Mon, 2005-07-11 at 16:07 +0200, Henning.Ramm at mediapro-gmbh.de wrote:
> Hi there!
> 
> I've a twisted app as database proxy server that handles all database queries for my other apps (via a pb connection).
> Now I get thousands of exceptions that I can't trace back, two kind:
> 
> 2005-07-11 15:57:36,707	defer.328	[ERROR]
> [Failure instance: Traceback: _mysql_exceptions.Warning: Datensätze gefunden: 1  Geändert: 0  Warnungen: 1
> D:\Python\lib\threading.py:422:run
> D:\Python\lib\site-packages\twisted\python\threadpool.py:145:_worker
> D:\Python\lib\site-packages\twisted\python\context.py:52:callWithContext
> D:\Python\lib\site-packages\twisted\python\context.py:31:callWithContext
> --- <exception caught here> ---
> D:\Python\lib\site-packages\twisted\internet\threads.py:25:_putResultInDeferred
> D:\Python\lib\site-packages\twisted\enterprise\adbapi.py:302:_runInteraction
> D:\Python\lib\site-packages\twisted\enterprise\adbapi.py:311:_runQuery
> D:\Python\lib\site-packages\MySQLdb\cursors.py:95:execute
> D:\Python\lib\site-packages\MySQLdb\cursors.py:114:_execute
> D:\Python\lib\site-packages\MySQLdb\connections.py:33:defaulterrorhandler
> ]
> 2005-07-11 15:57:36,707	defer.328	[ERROR]
> [Failure instance: Traceback: _mysql_exceptions.IntegrityError: (1062, "Doppelter Eintrag 'TA_V_23_130705' f\xfcr Schl\xfcssel 1.")
> D:\Python\lib\threading.py:422:run
> D:\Python\lib\site-packages\twisted\python\threadpool.py:145:_worker
> D:\Python\lib\site-packages\twisted\python\context.py:52:callWithContext
> D:\Python\lib\site-packages\twisted\python\context.py:31:callWithContext
> --- <exception caught here> ---
> D:\Python\lib\site-packages\twisted\internet\threads.py:25:_putResultInDeferred
> D:\Python\lib\site-packages\twisted\enterprise\adbapi.py:302:_runInteraction
> D:\Python\lib\site-packages\twisted\enterprise\adbapi.py:311:_runQuery
> D:\Python\lib\site-packages\MySQLdb\cursors.py:95:execute
> D:\Python\lib\site-packages\MySQLdb\cursors.py:114:_execute
> D:\Python\lib\site-packages\MySQLdb\connections.py:33:defaulterrorhandler
> ]
> 
> The first one is absolutely useless - MySQL tells me only that it could process the query ("datasets found: 1, changed 0, warning: 1"); I'd like to block that completely.
> 
> The second one means that I tried an insert with an existing key ("Double entry '...' for key 1"); also no problem, if I could handle it and do an update query instead.
> 
> But as you can see, I can't trace the messages back to one of my methods (and I have already every function call in a try..except clause).
> 
> Any hints?

These exceptions are happening in your Deferred callbacks. You need to
attach an error handler (the asynchronous counterpart to an except: 
clause) to the deferred you get back as a result of your adbapi call.

See twisted.internet.defer for more details.

dave






More information about the Twisted-Python mailing list