On Jun 15, 6:18 pm, James Gregory <james....@gmail.com> wrote:
> I am creating a web app with Django. I use a local MySQL database to
> store users etc, but also connect to a remote Oracle database to pull
> in some information to display.
>
> Due to Django's lack of multiple database support I have written my
> own very smalI Oracle wrapper, using cx_Oracle. In an effort to be
> more efficient, I create a new Oracle connection when my oracle python
> code is first included, and then only reconnect if the connection is
> closed. I note that Django's own database wrapper code does the same
> thing.
>
> This works fine when running with Django's development server, but if
> I:
> 1. Run my application via Apache and mod_wsgi
> 2. Then hit the server with two requests in rapid succession
>
> The second request displays a database error of "ORA-24909: call in
> progress. Current operation cancelled". It seems this is caused by
> attempting to use a database connection/cursor before the last query
> has finished - i.e. the Oracle client library doesn't like multiple
> threads attempting to use the same cursor simultanously.
>
> Questions:
> 1. Is this a bug in Oracle? I see some one web reference implying that
> this is a bug in Oracle version 10.2.0.1, and that is indeed the
> version I am using. However, I only get the error when multiple
> threads are attempting to use the same connection at the same time, so
> it might well be a valid error message regardless of version.
>
> 2. If it is not a bug in Oracle, then how does Django's own Oracle
> wrapper avoid this problem? I was reading through the source but can't
> see anything obvious.
>
> 3. If it is not a bug but Django's own wrapper doesn't deal with this
> problem, how do I deal with it? Should I simply create a new database
> connection for every single web request?
>
> James

Connections aren't thread safe - you have to ensure every thread gets
its own connection. You can create a new connection every request or
use a thread-local to cache connections.

Miles
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to