google-code-export / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
1 stars 0 forks source link

Decimal support is not multiple-interpreter safe (mod_python, mod_wsgi) #156

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We're using pyodbc to connect to DB2 with Django hosted in a mod_wsgi container 
in Apache. We sometimes get the exception 'Python type Decimal not supported.  
param=1', 'HY097' which renders the whole web-app unusable.

I've dug somewhat into this, and I think the problem is that pyodbc is storing 
a reference to the decimal class in import_types() in pyodbcmodule.cpp (I've 
looked at 2.1.8). There's a good explanation in the context of psycopg2 here, 
mod_python seems to have the same problem:

http://groups.google.com/group/webpy/msg/9f668fb9a549f759

Unfortunately, someone decided to break all the psycopg2 history and links, but 
you can find the latest code here, the function is psyco_GetDecimalType:

https://dndg.it/cgi-bin/gitweb.cgi?p=public/psycopg2.git;a=blob;f=psycopg/psycop
gmodule.c;h=f91483df5ba214eb5fed7f855673e9736b9cc980;hb=HEAD

The gist seems to be to always load the module in case we're running in a 
sub-interpreter instead of trying to cache it.

Original issue reported on code.google.com by olau%iol...@gtempaccount.com on 10 Feb 2011 at 11:43

GoogleCodeExporter commented 9 years ago

Original comment by mkleehammer on 28 Feb 2011 at 12:31